-
Notifications
You must be signed in to change notification settings - Fork 132
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
Design and implement Project SDK resolution that does not involve source-edits or SDK mutation. #3781
Comments
Are there things we can infer from the VMR build that would enable us to achieve the same result? |
I don't think so? I think the root of the issue is that SDKs are listed in global.json with their versions. The version of the SDK that we need to use in the build will be unknown until we build it. |
I agree that it is hacky. It copies binaries into the immutable .NET SDK directory. That means that developer won't be able to build with their globally installed SDK (when versions match). That would be very unfortunate as we worked really hard on supporting this in the individual repositories. https://github.com/dotnet/dotnet/blob/2017edaa9105ca502bc09f6f9cd0346ae2fecdff/eng/tools/tasks/SourceBuild.MSBuildSdkResolver/SourceBuild.MSBuildSdkResolver.csproj#L9C59-L9C92 and https://github.com/dotnet/dotnet/blob/6934a8c588bf8627c9e60aec98c156c3e00bf203/Directory.Build.props#L54C30-L54C42 |
Totally agree. IMO overriding of the versions of msbuild SDKs should be supported as first class concept. |
Would we still need this if we would cloak the global.json file in the individual repos away and unify them into the root global.json one? Or alternatively, if we would update the global.json SDK entries? |
We would. Because once you build arcade, you want to use that arcade SDK downstream. And ideally you do so without updating the root global.json. Same goes with the Windows desktop SDK |
@marcpopMSFT @dsplaisted @rainersigwald Any opinions here? Some ideas:
|
Yes the second option definitely sounds better if it would mean that we could express the override versions inside msbuild before the SDK is fetched and used. That would allow us to not depend on env vars. |
SDK resolvers don't have access to MSBuild properties, so I think it would still need to be environment variable based. It would be great to have the support to override SDK resolution built in. That will require it to be more complicated to ensure it's performant and appropriately cached. I think @ladipro has been working on performance improvements for the MSBuild SDK resolvers. |
The default .NET SDK resolver already has override support using
If these two environment variables are sufficient to support your scenario I think it would make sense to add them to the |
@ladipro does those env vars also work for other msbuild sdks, not just |
@ViktorHofer this would work for everything you put in the directory pointed to by So for |
That sounds great and would solve this issue.
Agreed. Do you have a rough ETA on when this work would be ready? |
This should be done by mid January. I still have a few days before the holidays but unless this is P1 for you, I will spend it finishing other work. |
It sounds like for the |
Would it be possible to specify multiple directories in that env var? I.e. |
This would be new functionality (in Have you considered using a local NuGet package source to restore the package from a local directory? That would let you use a custom SDK today in a less hacky / more supported way. |
Right, using the NuGet SDK resolver would be sufficient for what we need BUT we still need a way to override the msbuild sdk version specified in the global.json, i.e. we need to use the live produced version of the |
Aaah, I think I understand now. For the override to work at NuGet level, you'd need to change at least the contents of |
Right, exactly. As is mutating the local dotnet SDK. |
What does seem to be a general awkwardness is that while much of the build logic can be made customizable on the command line, via passing in global properties, global.json (and to a lesser extent, NuGet.config), are static data files that that require source level edits to customize. |
With global.json, does that have more to do with being ingrained in the host? |
I think that's the case for some elements of global.json, but I would be surprised if the host knows about the msbuild SDK versions? |
Right. The msbuild sdk section was added to global.json as they had to be stored somewhere outside of msbuild logic that doesn't require an evaluation. The host ignores that section. |
So after more days thinking about this, here's my take: We currently need to specify which msbuild sdks get live produced and should be extracted to an intermediate folder in the VMR so that subsequent repositories can depend on it. There are a lot of hardcodes involved (msbuild & env vars) and extracting the nuget packages leads to issues like wrong chmod permissions on Unix and is in-efficient. In addition to that, the current custom resolver is copied into the SDK toolset directory and with that mutates the immutable layout. Ideally the nuget sdk resolver component would provide a hook (i.e. env var) that allows to override a requested msbuild sdk's version. That would work for all cases that we have today inside the VMR and lets us utilize the components/infrastructure that our customers use (common path), instead of building a custom SDK resolver that is hard to get right. For in-built SDKs like Microsoft.NET.Sdk, switches are already exposed that make it possible to point to a specific local folder. As mentioned, we don't use a live Microsoft.NET.Sdk msbuild sdk in the VMR today, but probably want / should at some point. |
Tagging @jeffkl to comment on this.
Would you still like to have |
The NuGet-based MSBuild project SDK resolver gets its configuration from the If we wanted to completely override the NuGet-based MSBuild project SDK resolver with environment variables, that's just a feature we'd have to add. The package feeds and SDKs are potentially more structured data than an environment variable could handle but we can design that if needed.
Does the build system know ahead of time all of the MSBuild project SDKs and versions and only want those specified in an env var to be made available? Or would the overrides just apply to the ones that are known? |
Ideally we would enable that scenario already now so that we wouldn't be blocked when we decide to or realize that we need to use the live Microsoft.NET.Sdk.
The latter. We need to override msbuild sdk versions specified in global.json / directly in a project via the
We were thinking of having an env var per msbuild sdk and make the name similar to the output of NuGet's |
@jeffkl the VMR effort would strongly benefit from this feature. Another ask that recently came up is that the nuget sdk resolver should support the Should we file issues in nuget/home for those two asks or is this one sufficient to the track them? |
@ViktorHofer we have an existing issue about the SDK resolver not being able to respect MSBuild properties: NuGet/Home#7855 Feel free to file a new one about having it also respect versions from environment variables. |
Filed NuGet/Home#13301 |
Right now, the source-build infra uses a special msbuild sdk resolver https://github.com/dotnet/dotnet/tree/main/eng/tools/tasks/SourceBuild.MSBuildSdkResolver to enable using the correct msbuild SDK version when building a repo. We need behavior that achieves this for unified build. Is this the best option? I dunno.
For instance, when you build arcade initially, you want to use the arcade version that the VMR has, not what Arcade's global.json specifies. When you build any repo after arcade, you want to use the newly built arcade SDK, not what that repo mentions in its global.json either.
The custom SDK resolver feels a little bit hacky? Maybe maybe not.
T-Shirt Size: Large
The text was updated successfully, but these errors were encountered: