Skip to content

SetupOSSPecificProps target is not incremental #129265

Closed

Description

@tmat

Description

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
Image

Expected behavior

The target should be skipped.

Actual behavior

The target is not skipped.

Regression?

No response

Known Workarounds

No response

Configuration

No response

Other information

No response

Activity

  1. added
    untriaged
    on Jun 10, 2026
  2. dotnet-policy-service commented on Jun 10, 2026

    @dotnet-policy-service
    Contributor

    Tagging subscribers to this area: @agocke, @dotnet/ilc-contrib
    See info in area-owners.md if you want to be subscribed.

  3. MichalStrehovsky commented on Jun 11, 2026

    @MichalStrehovsky
    Member

    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.

  4. added this to the Future milestone on Jun 11, 2026
  5. removed
    untriaged
    on Jun 11, 2026
  6. tmat commented on Jun 11, 2026

    @tmat
    MemberAuthor

    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.

  7. MichalStrehovsky commented on Jun 12, 2026

    @MichalStrehovsky
    Member

    Would it be possible to use VS version as a key to the cache?

    That would work I guess. #129316 does it.

    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).

  8. added a commit that references this issue on Jun 18, 2026
    1f49500
  9. added a commit that references this issue on Jul 15, 2026
    8463c43
  10. locked and limited conversation to collaborators on Jul 18, 2026
  11. added a commit that references this issue on Jul 22, 2026
    d0dbddf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    • Status
      No status

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions