Skip to content
This repository was archived by the owner on Aug 3, 2024. It is now read-only.

Commit 900bef1

Browse files
authored
Make common build tools compatible with .NET 6 (#400)
Progress on NuGet/NuGetGallery#9149
1 parent 7475cb0 commit 900bef1

2 files changed

Lines changed: 22 additions & 52 deletions

File tree

build/common.ps1

Lines changed: 3 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
### Constants ###
2-
$DefaultMSBuildVersion = '16'
2+
$DefaultMSBuildVersion = '17'
33
$DefaultConfiguration = 'debug'
44
$NuGetClientRoot = Split-Path -Path $PSScriptRoot -Parent
55
$CLIRoot = Join-Path $NuGetClientRoot 'cli'
@@ -95,7 +95,7 @@ Function Get-LatestVisualStudioRoot {
9595

9696
Function Get-MSBuildExe {
9797
param(
98-
[ValidateSet("15", "16", $null)]
98+
[ValidateSet("15", "16", "17", $null)]
9999
[string]$MSBuildVersion
100100
)
101101

@@ -406,8 +406,6 @@ Function Install-NuGet {
406406

407407
$NuGetFolderPath = Split-Path -Path $NuGetExe -Parent
408408
$NuGetInstalledMarker = Join-Path $NuGetFolderPath ".marker.v1"
409-
$CredentialProviderDir = Join-Path $NuGetFolderPath "credprovider"
410-
$CredentialProviderPath = Join-Path $CredentialProviderDir "plugins\netfx\CredentialProvider.Microsoft\CredentialProvider.Microsoft.exe"
411409

412410
if (Test-Path $NuGetInstalledMarker) {
413411
Trace-Log "nuget.exe is already installed"
@@ -418,30 +416,10 @@ Function Install-NuGet {
418416
if (-not (Test-Path $NuGetFolderPath)) {
419417
New-Item $NuGetFolderPath -Type Directory | Out-Null
420418
}
421-
422-
$CredentialProviderBundle = (Join-Path $NuGetClientRoot '.nuget\Microsoft.NuGet.CredentialProvider.zip')
423-
424-
Trace-Log 'Downloading Azure Artifacts Credential Provider'
425-
Invoke-WebRequest `
426-
https://github.com/microsoft/artifacts-credprovider/releases/download/0.1.18/Microsoft.NuGet.CredentialProvider.zip `
427-
-UseBasicParsing `
428-
-OutFile $CredentialProviderBundle
429-
430-
if (Test-Path $CredentialProviderDir) {
431-
Remove-Item $CredentialProviderDir -Recurse -Force
432-
}
433-
434-
Trace-Log 'Extracting Azure Artifacts Credential Provider'
435-
& $7zipExe x $CredentialProviderBundle "-o$CredentialProviderDir" "-y"
436-
if ($LASTEXITCODE -ne 0) {
437-
throw "7-zip failed to extract $CredentialProviderBundle"
438-
}
439-
440-
Remove-Item $CredentialProviderBundle
441419

442420
Trace-Log 'Downloading nuget.exe'
443421
Invoke-WebRequest `
444-
https://dist.nuget.org/win-x86-commandline/v6.0.0-preview4/nuget.exe `
422+
https://dist.nuget.org/win-x86-commandline/v6.2.1/nuget.exe `
445423
-UseBasicParsing `
446424
-OutFile $NuGetExe
447425

@@ -451,36 +429,14 @@ Function Install-NuGet {
451429
if (Test-Path $NuGetExe) {
452430
Remove-Item $NuGetExe -Recurse -Force
453431
}
454-
if (Test-Path $CredentialProviderDir) {
455-
Remove-Item $CredentialProviderDir -Recurse -Force
456-
}
457-
if (Test-Path $NuGetInstalledMarker) {
458-
Remove-Item $NuGetInstalledMarker -Recurse -Force
459-
}
460432
throw;
461433
} finally {
462434
$progressPreference = 'Continue'
463435
}
464436
}
465-
466-
if (-not (Test-Path $CredentialProviderPath)) {
467-
throw "No file exists at the expected credential provider path: $CredentialProviderPath"
468-
}
469-
470437
if (-not (Test-Path $NuGetExe)) {
471438
throw "No file exists at the expected nuget.exe path: $NuGetExe"
472439
}
473-
474-
Trace-Log "Setting NuGet .NET Framework credential path"
475-
$env:NUGET_NETFX_PLUGIN_PATHS = $CredentialProviderPath
476-
$env:NUGET_PLUGIN_PATHS = $CredentialProviderPath
477-
478-
# This is a mitigation for rampant timeouts from the credential provider.
479-
# See https://github.com/NuGet/Home/issues/7842#issuecomment-531059076
480-
$timeoutInSeconds = 30
481-
Trace-Log "Increasing NuGet plug-in timeout values to $timeoutInSeconds seconds."
482-
$env:NUGET_PLUGIN_HANDSHAKE_TIMEOUT_IN_SECONDS = $timeoutInSeconds
483-
$env:NUGET_PLUGIN_REQUEST_TIMEOUT_IN_SECONDS = $timeoutInSeconds
484440
}
485441

486442
Function Configure-NuGetCredentials {

build/sign.microbuild.targets

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,17 +58,18 @@
5858
<!--
5959
Add fully qualified paths for the output and intermediate assemblies.
6060
-->
61-
<_OutputToSign Include="$(ProjectDir)%(IntermediateAssembly.Identity)" KeepDuplicates="false" />
62-
<_OutputToSign Include="$(TargetPath)" KeepDuplicates="false" />
61+
<_ManagedOutputToSign Include="$(ProjectDir)%(IntermediateAssembly.Identity)" KeepDuplicates="false" />
62+
<_ManagedOutputToSign Include="$(TargetPath)" KeepDuplicates="false" />
6363
<!--
6464
If we are batch signing, find all copies of the target file name in the repository. This handles the cases when
6565
there is a project reference pointing to the current project and there is a copy of this output assembly in the
6666
bin directory of another project. That assembly also needs to be signed.
6767
-->
68-
<_OutputToSign Include="$(RepositoryRootDirectory)**\$(TargetFileName)" Condition="'$(BatchSign)' == 'true'" />
68+
<_ManagedOutputToSign Include="$(RepositoryRootDirectory)**\$(TargetFileName)" Condition="'$(BatchSign)' == 'true' AND '$(TargetFileName)' != ''" />
69+
<_ManagedOutputToSign Remove="$(RunCommand)" Condition="'$(RunCommand)' != ''" />
6970
<UnfilteredFilesToSign
70-
Include="$([System.IO.Path]::GetFullPath('%(_OutputToSign.Identity)'))"
71-
Condition="Exists('%(_OutputToSign.Identity)')"
71+
Include="$([System.IO.Path]::GetFullPath('%(_ManagedOutputToSign.Identity)'))"
72+
Condition="Exists('%(_ManagedOutputToSign.Identity)')"
7273
KeepDuplicates="false">
7374
<Authenticode>Microsoft400</Authenticode>
7475
<StrongName>MsSharedLib72</StrongName>
@@ -87,6 +88,19 @@
8788
<Authenticode>Microsoft400</Authenticode>
8889
</UnfilteredFilesToSign>
8990

91+
<!--
92+
.NET Core entry points (like web projects) can have an native .exe produced along with the managed .dll. Sign that
93+
by default as well.
94+
-->
95+
<_UnmanagedOutputToSign Include="$(RunCommand)" KeepDuplicates="false" Condition="'$(BatchSign)' == 'true' AND '$(RunCommand)' != ''" />
96+
<_UnmanagedOutputToSign Include="$(RepositoryRootDirectory)**\apphost.exe" Condition="'$(BatchSign)' == 'true'" />
97+
<UnfilteredFilesToSign
98+
Include="$([System.IO.Path]::GetFullPath('%(_UnmanagedOutputToSign.Identity)'))"
99+
Condition="Exists('%(_UnmanagedOutputToSign.Identity)')"
100+
KeepDuplicates="false">
101+
<Authenticode>Microsoft400</Authenticode>
102+
</UnfilteredFilesToSign>
103+
90104
<!--
91105
Add fully qualified paths for checked in binaries. By convention, add common binaries that we use for jobs.
92106
-->

0 commit comments

Comments
 (0)