You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
SetupOSSPecificProps target is not incremental #129265
Every time publish is invoked we sped 6s in this target, even if nothing has changed in the source.
Reproduction Steps
Create console app with PublishAot = true.
Run dotnet publish multiple times without changing the source:
C:\Temp\publish-repro>dotnet publish --runtime win-x64 --self-contained true
Restore complete (6.7s)
info NETSDK1057: You are using a preview version of .NET. See: https://aka.ms/dotnet-support-policy
publish-repro net11.0 win-x64 succeeded (11.0s) → bin\Release\net11.0\win-x64\publish\
Build succeeded in 18.1s
C:\Temp\publish-repro>dotnet publish --runtime win-x64 --self-contained true -bl
Restore complete (0.5s)
info NETSDK1057: You are using a preview version of .NET. See: https://aka.ms/dotnet-support-policy
publish-repro net11.0 win-x64 succeeded (6.4s) → bin\Release\net11.0\win-x64\publish\
Build succeeded in 7.3s
C:\Temp\publish-repro>dotnet publish --runtime win-x64 --self-contained true -bl
Restore complete (0.5s)
info NETSDK1057: You are using a preview version of .NET. See: https://aka.ms/dotnet-support-policy
publish-repro net11.0 win-x64 succeeded (6.3s) → bin\Release\net11.0\win-x64\publish\
Build succeeded in 7.2s
This is a hard fix. A lot of code we don't have control over has dependencies on SetupOSSpecificProps (just a GitHub search finds tons of repos). SetupOSSpecificProps doesn't have inputs/outputs. On Windows it locates VS paths that have link.exe and various .lib files we need. It is pretty lightweight outside Windows. On Windows it's slow because vcvarsall.cmd is the slowest batch script in the world (in the "script that only sets some environment variables" category). We cannot cache any of those outputs because VS updates invalidate it. We only need to run this if e.g. the LinkNative target needs to run. I'm not aware of any way to express "this target can be skipped if this other target is skipped" in MSBuild.
We cannot cache any of those outputs because VS updates invalidate it
Would it be possible to use VS version as a key to the cache?
We only need to run this if e.g. the LinkNative target needs to run
If that's the case, then perhaps the target dependencies are not setup correctly. If I run publish multiple times, the input files of the native compilation pipeline that are produced by the managed build shouldn't be changing, so we shouldn't need to redo the native compilation, no? I don't think it is necessary to guarantee that the published binary was built using the latest version of the native tools.
If that's the case, then perhaps the target dependencies are not setup correctly
Possibly. The SetupOSSpecificProps is an odd target and is forced because we don't carry all our build dependencies (Visual Studio, Xcode, etc.). It doesn't have inputs or outputs because it only discovers what is on the machine so that later stages can use it. We have several targets that then use the discovered tools, so this should basically only run when those targets need to run.
We cannot really do much with this target because too much outside code depends on it for sequencing (sometimes they want to change what we discover or use what we found).
Activity
dotnet-policy-service commentedon Jun 10, 2026
Tagging subscribers to this area: @agocke, @dotnet/ilc-contrib
See info in area-owners.md if you want to be subscribed.
MichalStrehovsky commentedon Jun 11, 2026
This is a hard fix. A lot of code we don't have control over has dependencies on SetupOSSpecificProps (just a GitHub search finds tons of repos). SetupOSSpecificProps doesn't have inputs/outputs. On Windows it locates VS paths that have link.exe and various .lib files we need. It is pretty lightweight outside Windows. On Windows it's slow because vcvarsall.cmd is the slowest batch script in the world (in the "script that only sets some environment variables" category). We cannot cache any of those outputs because VS updates invalidate it. We only need to run this if e.g. the LinkNative target needs to run. I'm not aware of any way to express "this target can be skipped if this other target is skipped" in MSBuild.
tmat commentedon Jun 11, 2026
Would it be possible to use VS version as a key to the cache?
If that's the case, then perhaps the target dependencies are not setup correctly. If I run publish multiple times, the input files of the native compilation pipeline that are produced by the managed build shouldn't be changing, so we shouldn't need to redo the native compilation, no? I don't think it is necessary to guarantee that the published binary was built using the latest version of the native tools.
MichalStrehovsky commentedon Jun 12, 2026
That would work I guess. #129316 does it.
Possibly. The SetupOSSpecificProps is an odd target and is forced because we don't carry all our build dependencies (Visual Studio, Xcode, etc.). It doesn't have inputs or outputs because it only discovers what is on the machine so that later stages can use it. We have several targets that then use the discovered tools, so this should basically only run when those targets need to run.
We cannot really do much with this target because too much outside code depends on it for sequencing (sometimes they want to change what we discover or use what we found).
Cache NativeAOT Visual Studio tool discovery (#129316)
Cache NativeAOT Visual Studio tool discovery (#129316)
Cache NativeAOT Visual Studio tool discovery (dotnet#129316)