-
Notifications
You must be signed in to change notification settings - Fork 258
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
Proposal: implement a SdkResolver for NuGet packages #5220
Comments
This looks like a great idea! I've been looking for a good extension point for tool packages that need to participate in restore such as git versioning packages. Currently NuGet excludes these imports during restore since they can cause the 1st and 2nd restore results to differ. If this ran before hand it would solve the issue. Lineups is an interesting scenario here, this could work to override and set a specific set of packages. There are a few other parts to lineup though such as locking the the currently selected packages down for repeatable builds. |
I'll try a few things with SdkResolver and see how it goes. Do the items need to be named SDK? NuGet would need a good way to determine if these are actually packages or not since it would need to attempt finding these from all sources. |
There are some quirks here to think, through, such as deciding how to resolve the package version to use (i.e. when no version is provided) and making SDK lookup fast despite the need to hit the network.
The samples above were just one syntax. The value for SDK can come from an attribute on Project and Import as well: <Project Sdk="Community.FSharp.Sdk"> <Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" />
<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk/2.0.0" />
<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk/min=1.0.0" /> |
This sounds very interesting, because both as @emgarten said for git versioning packages and also for real SDKs. |
Early versions of the Microsoft.NET.SDK actually were NuGet packages. There's an issue on the backlog to make it available via NuGet -- dotnet/sdk#300 -- Btw, I think this resolver would help with some of the ideas you brought up in dotnet/msbuild#1756 |
Please don't reinvent this! This is the entire goal of MSBuild SDKs. We're making incremental progress in conjunction with the SDK team (and, I thought, the NuGet team, but this issue reveals that that understanding was wrong). cc @AndyGerlicher @Microsoft/msbuild-maintainers |
Can clarify what you're working on with the SDK team? The main thing I'm after is a way to install targets/tasks from arbitrary NuGet packages. PackageReference is not quite good enough for reasons listed above, so I opened this issue on NuGet as a way to improve the acquisition story for MSBuild targets/tasks. Is there something else in the works that would overlap with this? |
Just talked about this in MSBuild/SDK/NuGet sync today. This was cut from 15.3 planning primarily because of concerns about doing a blocking network call during project evaluation. Other concerns:
cc @rrelyea |
Consider and discuss post 15.3. As @rainersigwald said, this is not in plan for 15.3. |
MSBuild SDK spec, with many mentions of a NuGet resolver: dotnet/msbuild#1493. |
My ask when designing this feature is that it's not tied to .NET or TFM's. That is, it should ideally support any project type that uses CPS to enable it to have its own SDK. The example I'm thinking of right now is Rust, but it can apply to any other language/platform. |
I'm working on a project system based on CPS, and I'd like to distribute the build system as an Sdk (ideally a package Sdk). I can't use PackageReference because MSBuild seems to expect for at least one import for props and one for targets. Is this planned for the next VS/MSBuild/NuGet release? Also, is it possible to implement a custom Sdk resolver in my project system, without installing it to the MSBuild installation folder? |
I am working with the NuGet team to add this in the next release of MSBuild. |
I hit the same limitation too. |
I was wondering, if I want to load my own SDK without having to code my own resolver, would it be possible to extend the MSBuildSDKsPath mechanism to support multiple paths? Then on my build I can just 'append' to the current path. |
Sorry, just realised this is the nuget repo.. not the MSBuild/SDK one |
Closing in favor of dotnet/msbuild#2278 and https://github.com/jeffkl/NuGetSdkResolver. We are working with msbuild folks on this. On our side we are tracking #5919 for a download API that might be consumed by msbuild folks. |
MSBuild 15.3 includes an new API, Microsoft.Build.Framework.SdkResolver. (see dotnet/msbuild#2002). In theory, we could implement a
NuGetPackageSdkResolver
that resolves the "Sdk" property to files in the NuGet cache.Goal
Distribute versioned MSBuild tasks, targets, and other tooling as a NuGet package.
Usage
In this example,
Microsoft.Net.Sdk
is not a nuget package, so the resolver would no-op.On the other hand,
Microsoft.NET.Test.Sdk
andmy.team.shared.buildsettings
are nuget packages that contains MSbuild targets and tasks. The resolver could download these packages to make them available to MSBuild.Layout of an "SDK" package
What the resolver does
(pseudocode)
Why not just use a PackageReference?
Many simple scenarios are already solved by adding build assets to a package, however, MSBuild tooling from an NuGet package still has some limitations:
msbuild /t:Restore && msbuild /t:Build
. Just runningmsbuild /t:Restore;Build
causes issues becausenuget.g.targets
andUsingTasks
are not resolved soon enough.TargetFramework
to make PackageReference work. This property only makes sense for csproj, but doesn't have meaning for MSBuild scripts that do other build automation.PrivateAssets=All
to avoid having tooling packages end up in the generated nuspec.One possibility
If this were implemented, I could easily create a package that looks like this:
This could solve the "Lineups" feature. #2572
cc @emgarten @AndyGerlicher @AArnott @nguerrera
The text was updated successfully, but these errors were encountered: