Fix Microsoft.Build.NoTargets missing in prep-source-build offline scenarios #2010
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When building .NET 10.0.0-preview.6 in offline/sandboxed environments without networking,
prep-source-build.sh
fails with SDK resolution errors:This happens because
eng/init-detect-binaries.proj
uses<Project Sdk="Microsoft.Build.NoTargets">
but the prep script lacks the offline SDK setup logic thatbuild.sh
has.Root Cause
The
prep-source-build.sh
script was missing the environment variable setup that enables theUnifiedBuildSdkResolver
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:eng/common/setup-offline-sdks.sh
prep-source-build.sh
to call this setup before running binary detectionSOURCE_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
Behavior
The fix follows the approach recommended in the issue discussion: duplicating/modifying the necessary logic from
build.sh
andinit-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
./.dotnet/dotnet restore eng/tools/tasks/Microsoft.DotNet.UnifiedBuild.MSBuildSdkResolver/Microsoft.DotNet.UnifiedBuild.MSBuildSdkResolver.csproj --verbosity quiet
(dns block)i1qvsblobprodcus353.vsblob.vsassets.io
/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
./.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.