Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit 9cf8b4b

Browse files
authored
Restore IBCMerge using an authenticated service connection (#24284)
* Add separate build steps to do the IBCMerge restore. * Attempt 1 to get config picked up. * Attempt 2 getting ibcmerge restore working. * Fix invalid MSBuild syntax. * Fix getting IBC package version.
1 parent 64b5ddd commit 9cf8b4b

File tree

4 files changed

+42
-7
lines changed

4 files changed

+42
-7
lines changed

build.cmd

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -670,11 +670,7 @@ if %__BuildCoreLib% EQU 1 (
670670
for /f "tokens=*" %%s in ('call "%__ProjectDir%\dotnet.cmd" msbuild "!IbcMergeProjectFilePath!" /t:DumpIbcMergePackageVersion /nologo') do @(
671671
set __IbcMergeVersion=%%s
672672
)
673-
674-
echo Restoring IBCMerge version !__IbcMergeVersion!...
675-
echo Running: %__ProjectDir%\dotnet.cmd restore src/.nuget/optdata/ibcmerge.csproj --no-cache --packages "%__PackagesDir%" --source "https://devdiv.pkgs.visualstudio.com/_packaging/dotnet-core-internal-tooling/nuget/v3/index.json"
676-
call %__ProjectDir%\dotnet.cmd restore src/.nuget/optdata/ibcmerge.csproj --no-cache --packages "%__PackagesDir%" --source "https://devdiv.pkgs.visualstudio.com/_packaging/dotnet-core-internal-tooling/nuget/v3/index.json"
677-
673+
678674
set IbcMergePath=%__PackagesDir%\microsoft.dotnet.ibcmerge\!__IbcMergeVersion!\tools\netcoreapp2.0\ibcmerge.dll
679675
if exist !IbcMergePath! (
680676
echo %__MsgPrefix%Optimizing using IBC training data
@@ -754,7 +750,7 @@ if %__BuildCoreLib% EQU 1 (
754750
goto CrossgenFailure
755751
)
756752
) else (
757-
echo Could not find IBCMerge at !IbcMergePath!
753+
echo Could not find IBCMerge at !IbcMergePath!. Have you restored src/.nuget/optdata/ibcmerge.csproj?
758754
goto CrossgenFailure
759755
)
760756
)

eng/build-job.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,26 @@ jobs:
101101
- script: eng\common\init-tools-native.cmd -InstallDirectory $(Build.SourcesDirectory)\native-tools -Force
102102
displayName: Install native dependencies
103103

104+
# Install internal tools on official builds
105+
# Since our internal tools are behind an authenticated feed,
106+
# we need to use the DotNetCli AzDO task to restore from the feed using a service connection.
107+
# We can't do this from within the build, so we need to do this as a separate step.
108+
- ${{ if and(and(eq(variables['System.TeamProject'], 'internal'), ne(variables['Build.Reason'], 'PullRequest')), eq(parameters.osGroup, 'Windows_NT')) }}:
109+
- task: DotNetCoreInstaller@0
110+
inputs:
111+
packageType: 'sdk'
112+
version: '2.1.503'
113+
- task: DotNetCoreCLI@2
114+
displayName: Restore internal tools
115+
inputs:
116+
command: restore
117+
feedsToUse: config
118+
projects: 'src/.nuget/optdata/ibcmerge.csproj'
119+
nugetConfigPath: 'eng/internal/NuGet.config'
120+
restoreDirectory: '$(Build.SourcesDirectory)\packages'
121+
verbosityRestore: 'normal'
122+
externalFeedCredentials: 'dotnet-core-internal-tooling'
123+
104124
# Build
105125
- ${{ if ne(parameters.osGroup, 'Windows_NT') }}:
106126
- script: ./build.sh $(buildConfig) $(archType) $(crossArg) -skiptests -skipnuget $(clangArg) $(stripSymbolsArg) $(officialBuildIdArg)

eng/internal/NuGet.config

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<configuration>
2+
<!-- Don't use any higher level config files.
3+
Our builds need to be isolated from user/machine state -->
4+
<fallbackPackageFolders>
5+
<clear />
6+
</fallbackPackageFolders>
7+
<packageSources>
8+
<clear/>
9+
<add key="dotnet-core-internal-tooling" value="https://devdiv.pkgs.visualstudio.com/_packaging/dotnet-core-internal-tooling/nuget/v3/index.json" />
10+
</packageSources>
11+
<disabledPackageSources>
12+
<clear />
13+
</disabledPackageSources>
14+
</configuration>

src/.nuget/optdata/ibcmerge.csproj

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,16 @@
99
</PropertyGroup>
1010

1111
<ItemGroup>
12-
<PackageReference Include="microsoft.dotnet.ibcmerge" Version="$(IbcMergePackageVersion)" Condition="'$(IbcMergePackageVersion)'!=''" />
12+
<PackageReference Include="microsoft.dotnet.ibcmerge" Version="[$(IbcMergePackageVersion)]" Condition="'$(IbcMergePackageVersion)'!=''" />
1313
</ItemGroup>
1414

1515
<Target Name="DumpIbcMergePackageVersion">
1616
<Message Importance="high" Text="$(IbcMergePackageVersion)" />
1717
</Target>
1818

19+
<PropertyGroup>
20+
<RestoreSources>
21+
https://devdiv.pkgs.visualstudio.com/_packaging/dotnet-core-internal-tooling/nuget/v3/index.json;
22+
</RestoreSources>
23+
</PropertyGroup>
1924
</Project>

0 commit comments

Comments
 (0)