Skip to content

Fix Microsoft.Build.NoTargets missing in prep-source-build offline scenarios #2010

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

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Aug 20, 2025

When building .NET 10.0.0-preview.6 in offline/sandboxed environments without networking, prep-source-build.sh fails with SDK resolution errors:

error : Could not resolve SDK "Microsoft.Build.NoTargets"
error : Unable to find package Microsoft.Build.NoTargets. No packages exist with this id in source(s): dotnet-eng, dotnet-libraries, dotnet-public

This happens because eng/init-detect-binaries.proj uses <Project Sdk="Microsoft.Build.NoTargets"> but the prep script lacks the offline SDK setup logic that build.sh has.

Root Cause

The prep-source-build.sh script was missing the environment variable setup that enables the UnifiedBuildSdkResolver to resolve SDKs from local bootstrap packages instead of online NuGet feeds.

Solution

This PR implements the same offline SDK resolution approach used in build.sh, adapted for the prep scenario:

  1. Extracts shared SDK setup logic into eng/common/setup-offline-sdks.sh
  2. Modifies prep-source-build.sh to call this setup before running binary detection
  3. Sets up environment variables that enable offline SDK resolution:
    • SOURCE_BUILT_SDK_ID_NOTARGETS=Microsoft.Build.NoTargets
    • SOURCE_BUILT_SDK_VERSION_NOTARGETS=3.7.0 (from global.json)
    • SOURCE_BUILT_SDK_DIR_NOTARGETS=~/.nuget/packages/BootstrapPackages/microsoft.build.notargets/3.7.0
  4. Extracts SDK packages from PSB (Previously Source Built) artifacts to the BootstrapPackages folder
  5. Provides clear diagnostics when packages are missing

Behavior

  • With PSB artifacts available: Extracts SDK packages and sets up offline resolution
  • Without PSB artifacts: Sets up environment variables from global.json and provides helpful error messages
  • Maintains backward compatibility with existing workflows

The fix follows the approach recommended in the issue discussion: duplicating/modifying the necessary logic from build.sh and init-source-only.proj for prep to support offline builds.

Fixes #2009.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • ckzvsblobprodcus347.vsblob.vsassets.io
    • Triggering command: ./.dotnet/dotnet restore eng/tools/tasks/Microsoft.DotNet.UnifiedBuild.MSBuildSdkResolver/Microsoft.DotNet.UnifiedBuild.MSBuildSdkResolver.csproj --verbosity quiet (dns block)
  • i1qvsblobprodcus353.vsblob.vsassets.io
    • Triggering command: /home/REDACTED/work/dotnet/dotnet/.dotnet/dotnet build /home/REDACTED/work/dotnet/dotnet/eng/init-detect-binaries.proj /p:BinariesMode=Clean /p:AllowedBinariesFile=/home/REDACTED/work/dotnet/dotnet/eng/allowed-sb-binaries.txt /p:BinariesPackagesDir=/tmp/mock-psb-packages /bl:artifacts/log/prep-remove-binaries.binlog /fileLoggerParameters:LogFile=artifacts/log/prep-remove-binaries.log (dns block)
  • pdfvsblobprodcus380.vsblob.vsassets.io
    • Triggering command: ./.dotnet/dotnet restore eng/tools/tasks/Microsoft.DotNet.UnifiedBuild.MSBuildSdkResolver/Microsoft.DotNet.UnifiedBuild.MSBuildSdkResolver.csproj --verbosity quiet (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copy link
Contributor Author

Copilot AI commented Aug 20, 2025

@MichaelSimons 👋 This repository doesn't have Copilot instructions. With Copilot instructions, I can understand the repository better, work faster and produce higher quality PRs.

I can generate a .github/copilot-instructions.md file for you automatically. Click here to open a pre-filled issue and assign it to me. I'll write the instructions, and then tag you for review.

Copilot AI and others added 2 commits August 20, 2025 14:05
Co-authored-by: MichaelSimons <8290530+MichaelSimons@users.noreply.github.com>
…traction

Co-authored-by: MichaelSimons <8290530+MichaelSimons@users.noreply.github.com>
@Copilot Copilot AI changed the title [WIP] Microsoft.Build.NoTargets missing in prep-source-build on 10.0.0-preview.6 Fix Microsoft.Build.NoTargets missing in prep-source-build offline scenarios Aug 20, 2025
Copilot finished work on behalf of MichaelSimons August 20, 2025 14:18
@Copilot Copilot AI requested a review from MichaelSimons August 20, 2025 14:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

Microsoft.Build.NoTargets missing in prep-source-build on 10.0.0-preview.6
2 participants