Skip to content

Add a second .NET path for MicroBuild#16091

Merged
ellahathaway merged 4 commits intodotnet:mainfrom
ellahathaway:microbuild-install-location
Oct 20, 2025
Merged

Add a second .NET path for MicroBuild#16091
ellahathaway merged 4 commits intodotnet:mainfrom
ellahathaway:microbuild-install-location

Conversation

@ellahathaway
Copy link
Member

@ellahathaway ellahathaway commented Aug 28, 2025

Resolves #15731

  • Separates out .NET used for tooling and .NET used for MicroBuild
  • Adds logic to require .NET for MicroBuild when not dry run signing
  • Finds .NET for MicroBuild by searching the path for a dotnet executable in a MicroBuild folder, defaults to the DotNetTool executable if not found or on Windows.
  • Updates the install-microbuild.yml file to install MicroBuild sources into a temp directory and the .NET version required by MicroBuild into the same temp directory

Arcade-validation test build

mmitche
mmitche previously approved these changes Sep 3, 2025
@akoeplinger
Copy link
Member

I just ran into the microbuild-deleted-by-checkout issue again in a repo, would be nice to have this finally fixed :)

@ellahathaway
Copy link
Member Author

I just ran into the microbuild-deleted-by-checkout issue again in a repo, would be nice to have this finally fixed :)

Acknowledged :) This fell off of my radar with some of the other work I've been focusing on. I will have it completed by end of the week.

@ellahathaway
Copy link
Member Author

@ellahathaway ellahathaway enabled auto-merge (squash) September 25, 2025 23:11
akoeplinger
akoeplinger previously approved these changes Oct 15, 2025
@ellahathaway ellahathaway merged commit 16f3dcc into dotnet:main Oct 20, 2025
10 checks passed
@ellahathaway ellahathaway deleted the microbuild-install-location branch October 20, 2025 16:06
@ellahathaway
Copy link
Member Author

/backport to release/10.0

@github-actions
Copy link
Contributor

@eerhardt
Copy link
Member

@ellahathaway - I think this broke dotnet/aspire's official build.

https://dev.azure.com/dnceng/internal/_build/results?buildId=2826933&view=logs&j=ab19ba8f-7bc9-572a-65fc-b6efe2f6eec8&t=6d4a8515-22ea-536e-cf14-1d8f3a0666a4

Starting: Install MicroBuild plugin (Windows)
==============================================================================
Task         : MicroBuild Signing Plugin
Description  : Installs and configures the MicroBuild signing plugin for use during the build
Version      : 4.101.166
Author       : Microsoft
Help         : This step should be added before the MSBuild/Visual Studio Build step
==============================================================================
signType: real
zipSources: false
version: latest
feedSource: https://dnceng.pkgs.visualstudio.com/_packaging/MicroBuildToolset/nuget/v3/index.json
skipAssetTest: false
ConnectedPMEServiceName: c24de2a5-cc7a-493d-95e4-8e5ff5cad2bc
Configuring the Plugins folder: /Users/runner/work/_temp/MicroBuild/MicroBuild/Plugins
Attempting to download MicroBuild.Plugins.Signing
/Users/runner/work/_temp/.dotnet-microbuild/dotnet nuget add source https://dnceng.pkgs.visualstudio.com/_packaging/MicroBuildToolset/nuget/v3/index.json --name internal 1309 Feed --configfile /Users/runner/work/_temp/MicroBuild/MicroBuild/Plugins/nuget.config --username ado --password *** --store-password-in-clear-text
The command could not be loaded, possibly because:
  * You intended to execute a .NET application:
      The application 'nuget' does not exist.
  * You intended to execute a .NET SDK command:
      A compatible .NET SDK was not found.

Requested SDK version: 10.0.100-rc.2.25502.107
global.json file: /Users/runner/work/1/s/global.json

Installed SDKs:

Install the [10.0.100-rc.2.25502.107] .NET SDK or update [/Users/runner/work/1/s/global.json] to match an installed SDK.

Learn about SDK resolution:
https://aka.ms/dotnet/sdk-not-found
8.0.415 [/Users/runner/work/_temp/.dotnet-microbuild/sdk]

##[error]Error: The process '/Users/runner/work/_temp/.dotnet-microbuild/dotnet' failed with exit code 145
Nuget.config authenticated successfully
Creating temporary restore project: /Users/runner/work/_temp/MicroBuild/MicroBuild.csproj
/Users/runner/work/_temp/.dotnet-microbuild/dotnet new console --force --no-restore --output /Users/runner/work/_temp/MicroBuild
The command could not be loaded, possibly because:
  * You intended to execute a .NET application:
      The application 'new' does not exist.
  * You intended to execute a .NET SDK command:
      A compatible .NET SDK was not found.

Requested SDK version: 10.0.100-rc.2.25502.107
global.json file: /Users/runner/work/1/s/global.json

Installed SDKs:

Install the [10.0.100-rc.2.25502.107] .NET SDK or update [/Users/runner/work/1/s/global.json] to match an installed SDK.

Learn about SDK resolution:
https://aka.ms/dotnet/sdk-not-found
8.0.415 [/Users/runner/work/_temp/.dotnet-microbuild/sdk]

I'm reverting to a previous version of dotnet/arcade. But can you take a look to see if we are doing something wrong?

@ellahathaway
Copy link
Member Author

@ellahathaway - I think this broke dotnet/aspire's official build.

@eerhardt - I found #15946, which describes an error message that's almost identical to what you've included above. My comment on that issue has an explanation of why this error occurs. What I'm not understanding is why this only happens in aspire and not in other repos like arcade or arcade-validation, where my changes in this PR have been successful (https://dev.azure.com/dnceng/internal/_build/results?buildId=2826588&view=results https://dev.azure.com/dnceng/internal/_build/results?buildId=2826600&view=results).

@akoeplinger
Copy link
Member

interesting, so it picked up global.json file: /Users/runner/work/1/s/global.json even though we're running from /Users/runner/work/_temp/.dotnet-microbuild/dotnet.

is the working directory not getting set to the correct path?

@radical
Copy link
Member

radical commented Oct 30, 2025

interesting, so it picked up global.json file: /Users/runner/work/1/s/global.json even though we're running from /Users/runner/work/_temp/.dotnet-microbuild/dotnet.

is the working directory not getting set to the correct path?

Yeah, I found the same thing. Did you mean setting DOTNET_ROOT? or microbuild needs to set CWD when it is running dotnet?

The issue seems to be that MicroBuild now uses its own dotnet. See https://dev.azure.com/dnceng/internal/_build/results?buildId=2828021&view=logs&j=ab19ba8f-7…

we store the sdks from global.json;

  • you can see the system sdk and the one installed by arcade in the repo;
  • And I tried adding the later to PATH also, and confirmed in the next step
  • But in the Install MicroBuild plugin (Windows) step it still fails. and if you see in the log it shows this at the end:
Learn about SDK resolution:

https://aka.ms/dotnet/sdk-not-found

8.0.415 [/Users/runner/work/_temp/.dotnet-microbuild/sdk]

##[error]Unhandled: The process '/Users/runner/work/_temp/.dotnet-microbuild/dotnet' failed with exit code 145

So it using its own dotnet but clashing with global.json.

@ellahathaway
Copy link
Member Author

I'm a bit stumped here. @mmitche - any ideas?

@akoeplinger
Copy link
Member

akoeplinger commented Oct 31, 2025

Yes I meant setting the CWD to the .dotnet-microbuild path, it's in the temp directory so it shouldn't pick up global.json from the repo sources path.

@mmitche
Copy link
Member

mmitche commented Oct 31, 2025

I'm a bit stumped here.

I think the root of the problem (why it fails for aspire) has something to do with the pre-step Restore. That would install and put a version of .NET on the path. My hunch is that if you remove this, then it will pass.

Before the SDK installation location change, the 8.0 SDK would have been installed at s/.dotnet. Btw, I think this would have eventually caused issues. Unless UseDotNet@2 has good logic, it would have overwritten the .NET 10 host, I think. That might do interesting things at some point.

There's maybe an issue in the MB install step. Their logic just uses the dotnet on the path. No working directory:

        await tl.exec('dotnet', `add ${restoreProjPath} package ${packageName} --version ${packageVersion} --no-restore`);
        let dotnetArgs = `restore ${restoreProjPath} --packages ${pluginFolder} --configfile ${nugetConfigPath}`;

        try {
            await tl.exec('dotnet', dotnetArgs);

What I'm really stumped about is why arcade-validation doesn't fail for MacOS. In https://dev.azure.com/dnceng/internal/_build/results?buildId=2827170&view=logs&j=ab19ba8f-7bc9-572a-65fc-b6efe2f6eec8&t=5374bfbb-e95e-576d-70e0-582c47a3d139, the 8.0 SDK gets installed. I would not expect that the behavior would be any different from aspire's. The global.json should get picked up from the root source directory, which would be a 10.0 RC2 SDK, and it's not available.

My hunch is that something in tools.sh influences the environment in some way when the first restore step happens. But I'm not sure what.

@mmitche
Copy link
Member

mmitche commented Oct 31, 2025

There it is. Restore is a red herring here. The thing is that arcade-validation, like many .NET repositories, doesn't use an sdk element in the global.json. Only tools. As soon as I introduced the sdk element, we get a failure because the host wants to find the rc2 SDK. Before @ellahathaway's recent change, that SDK existed underneath .dotnet due to the initial restore. Afterward, the new install location prepends to the path, and the RC2 sdk isn't found underneath that dotnet root due based on the host lookup behavior.

I think @ellahathaway's code is correct for the signing step itself. The intention is that step uses the 8.0 SDK. I am suspicious that prepending an 8.0 SDK to the path after the initial restore step will have negative downstream effects, though. It might just work now because the arcade tooling keeps info around about where its original install was.

You have some options...

  • Emit a global.json into the temp directory where the MB install happens and update the microbuild plugin to take some CWD path.
  • Rely on the repo to restore the global.json referenced SDK before installing the MB plugin, and install the 8.0 SDK afterward.
  • Revert the change altogether. Rely on the repo to restore the global.json SDK. Install the 8.0 SDK. Fix all the places where teams are checking out explicitly with a clean.

I thiiiink I'm a fan of the first option. It gives the ability to separate out the repo's infra from microbuild's, fully. The only thing I don't love is that UseDotNet@2 still prepends to the path. Why does it not have an option NOT to do so. We could switch to something else, though.

@ellahathaway
Copy link
Member Author

Starting: Install MicroBuild plugin (Windows)

Task : MicroBuild Signing Plugin
Description : Installs and configures the MicroBuild signing plugin for use during the build
Version : 4.101.166
Author : Microsoft
Help : This step should be added before the MSBuild/Visual Studio Build step

signType: real
zipSources: false
version: latest
feedSource: https://dnceng.pkgs.visualstudio.com/_packaging/MicroBuildToolset/nuget/v3/index.json
skipAssetTest: false
ConnectedPMEServiceName: c24de2a5-cc7a-493d-95e4-8e5ff5cad2bc
Configuring the Plugins folder: /Users/runner/work/_temp/MicroBuild/MicroBuild/Plugins
Attempting to download MicroBuild.Plugins.Signing
/Users/runner/work/_temp/.dotnet-microbuild/dotnet nuget add source https://dnceng.pkgs.visualstudio.com/_packaging/MicroBuildToolset/nuget/v3/index.json --name internal 1309 Feed --configfile /Users/runner/work/_temp/MicroBuild/MicroBuild/Plugins/nuget.config --username ado --password *** --store-password-in-clear-text
The command could not be loaded, possibly because:

  • You intended to execute a .NET application:
    The application 'nuget' does not exist.
  • You intended to execute a .NET SDK command:
    A compatible .NET SDK was not found.

Requested SDK version: 10.0.100-rc.2.25502.107
global.json file: /Users/runner/work/1/s/global.json

Installed SDKs:

Install the [10.0.100-rc.2.25502.107] .NET SDK or update [/Users/runner/work/1/s/global.json] to match an installed SDK.

Learn about SDK resolution:
https://aka.ms/dotnet/sdk-not-found
8.0.415 [/Users/runner/work/_temp/.dotnet-microbuild/sdk]

##[error]Error: The process '/Users/runner/work/_temp/.dotnet-microbuild/dotnet' failed with exit code 145
Nuget.config authenticated successfully
Creating temporary restore project: /Users/runner/work/_temp/MicroBuild/MicroBuild.csproj
/Users/runner/work/_temp/.dotnet-microbuild/dotnet new console --force --no-restore --output /Users/runner/work/_temp/MicroBuild
The command could not be loaded, possibly because:

  • You intended to execute a .NET application:
    The application 'new' does not exist.
  • You intended to execute a .NET SDK command:
    A compatible .NET SDK was not found.

Requested SDK version: 10.0.100-rc.2.25502.107
global.json file: /Users/runner/work/1/s/global.json

Installed SDKs:

Install the [10.0.100-rc.2.25502.107] .NET SDK or update [/Users/runner/work/1/s/global.json] to match an installed SDK.

Learn about SDK resolution:
https://aka.ms/dotnet/sdk-not-found

Thank you, Matt. I've filed #16259 in response to this. I'm currently working with the MicroBuild team to get this resolved.

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.

[Signing] Avoid installing MicroBuild plugin to sources directory

5 participants