Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automate chat template .NET dependency updates #5946

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

MackinnonBuck
Copy link
Member

@MackinnonBuck MackinnonBuck commented Feb 20, 2025

This PR makes the following changes:

  1. Running the template locally will use the locally built Microsoft.Extensions.AI* packages.
  2. Project template .NET dependencies are managed in Versions.props (just like other .NET dependencies).
  3. New README instructions were added to explain how to test the templates locally.

Fixes https://github.com/dotnet/ai-private-planning/issues/276

Microsoft Reviewers: Open in CodeFlow

<!-- We do this after the initial evaluation of this project file so all properties have been initialized. -->
<_GeneratedContentRepoProperties>
ArtifactsShippingPackagesDir=$(ArtifactsShippingPackagesDir);
RepoPackageVersion=$(Version);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ASP.NET Core repo does something more advanced than this for references to packages defined in the same repo (it runs an MSBuild task on each referenced project and extracts the actual package versions). However, when I collected a binlog, it revealed that all referenced packages had identical versions anyway. So, I've taken a simpler approach here and just used $(Version), because AFAICT it will be the same across all packages in this repo. If that assumption is wrong, or if someone thinks it would be more robust to do a different approach, I'd be happy to consider it.

Comment on lines +12 to +14
<Error
Condition="!Exists('${ArtifactsShippingPackagesDir}')"
Text="Repo packages must be built locally before running this project. See src/ProjectTemplates/README.md for more info." />
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is only here so that you don't get a cryptic NuGet error if you forget to generate M.E.AI NuGet packages.

Comment on lines +10 to +14
<packageSourceMapping>
<packageSource key="local-shipping">
<package pattern="*" />
</packageSource>
</packageSourceMapping>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is required in order for the locally generated packages to get picked up during restore. I'm not 100% sure of the reason, but I think it's because the <packageSourceMapping> declared in the repo's root NuGet.config resulted in another package source getting used to resolve the Microsoft.Extensions.AI package reference, even though that source doesn't have the correct version.

If the <packageSourceMapping> element weren't required here, we could have removed this entire file and instead just modified <RestoreAdditionalProjectSources> in the Directory.Build.targets.in file.

Comment on lines +22 to +25
**Note:** Since package versions don't change between local builds, it may be necessary to occasionally delete `Microsoft.Extensions.AI*` packages from your local nuget cache, especially if you're making changes to these packages. An example of how to do this in PowerShell is:
```pwsh
Remove-Item ~\.nuget\packages\microsoft.extensions.ai* -Recurse -Force
```
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's unfortunate that this is the case, but I'm not aware of a better alternative. Maybe we could create scripts that build/run the template using a local nuget package cache. The cache would get cleared (or partially cleared) when the build detects that local packages have been updated. But I'm not sure if the effort to create and maintain that infrastructure is worth it, and I'm inclined to keep things simple for now.

@dotnet-comment-bot
Copy link
Collaborator

‼️ Found issues ‼️

Project Coverage Type Expected Actual
Microsoft.Extensions.AI Line 89 88.76 🔻

🎉 Good job! The coverage increased 🎉
Update MinCodeCoverage in the project files.

Project Expected Actual
Microsoft.Gen.MetadataExtractor 57 70
Microsoft.Extensions.AI.Abstractions 82 83

Full code coverage report: https://dev.azure.com/dnceng-public/public/_build/results?buildId=957249&view=codecoverage-tab

Comment on lines +78 to +81
<!-- Dependencies from https://github.com/dotnet/efcore -->
<MicrosoftEntityFrameworkCoreSqliteVersion>9.0.2</MicrosoftEntityFrameworkCoreSqliteVersion>
<!-- Dependencies from https://github.com/dotnet/arcade -->
<MicrosoftDotNetBuildTasksTemplatingVersion>9.0.0-beta.25111.5</MicrosoftDotNetBuildTasksTemplatingVersion>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that these two dependencies are the only ones that will be automatically updated. Third party dependencies are put lower in this file (in the "Manual" group) and will need to be manually updated. And, of course, any template dependencies defined in the extensions repo (such as Microsoft.Extensions.AI) inherit the repo-defined version and therefore implicitly stay up to date.

@dotnet-comment-bot
Copy link
Collaborator

‼️ Found issues ‼️

Project Coverage Type Expected Actual
Microsoft.Extensions.AI Line 89 88.52 🔻

🎉 Good job! The coverage increased 🎉
Update MinCodeCoverage in the project files.

Project Expected Actual
Microsoft.Extensions.AI.Abstractions 82 83
Microsoft.Gen.MetadataExtractor 57 70

Full code coverage report: https://dev.azure.com/dnceng-public/public/_build/results?buildId=957975&view=codecoverage-tab

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants