Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions eng/common/core-templates/steps/install-microbuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,23 @@ parameters:
# Unfortunately, _SignType can't be used to exclude the use of the service connection in non-real sign scenarios. The
# variable is not available in template expression. _SignType has a very large proliferation across .NET, so replacing it is tough.
microbuildUseESRP: true
# Location of the MicroBuild output folder
# NOTE: There's something that relies on this being in the "default" source directory for tasks such as Signing to work properly.
microBuildOutputFolder: '$(Build.SourcesDirectory)'

continueOnError: false

steps:
- ${{ if eq(parameters.enableMicrobuild, 'true') }}:
- ${{ if eq(parameters.enableMicrobuildForMacAndLinux, 'true') }}:
# Installing .NET 8 is required to use the MicroBuild signing plugin on non-Windows platforms
# Needed to download the MicroBuild plugin nupkgs on Mac and Linux when nuget.exe is unavailable
- task: UseDotNet@2
displayName: Install .NET 8.0 SDK for MicroBuild Plugin
inputs:
packageType: sdk
version: 8.0.x
# Installing the SDK in a '.dotnet-microbuild' directory is required for signing.
# See target FindDotNetPathForMicroBuild in arcade/src/Microsoft.DotNet.Arcade.Sdk/tools/Sign.proj
# Do not remove '.dotnet-microbuild' from the path without changing the corresponding logic.
installationPath: $(Agent.TempDirectory)/.dotnet-microbuild
installationPath: ${{ parameters.microBuildOutputFolder }}/.dotnet
workingDirectory: ${{ parameters.microBuildOutputFolder }}
condition: and(succeeded(), ne(variables['Agent.Os'], 'Windows_NT'))

- script: |
Expand Down Expand Up @@ -64,7 +65,7 @@ steps:
ConnectedPMEServiceName: 248d384a-b39b-46e3-8ad5-c2c210d5e7ca
env:
TeamName: $(_TeamName)
MicroBuildOutputFolderOverride: $(Agent.TempDirectory)/MicroBuild
MicroBuildOutputFolderOverride: ${{ parameters.microBuildOutputFolder }}
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
continueOnError: ${{ parameters.continueOnError }}
condition: and(succeeded(), eq(variables['Agent.Os'], 'Windows_NT'), in(variables['_SignType'], 'real', 'test'))
Expand All @@ -84,7 +85,7 @@ steps:
ConnectedPMEServiceName: c24de2a5-cc7a-493d-95e4-8e5ff5cad2bc
env:
TeamName: $(_TeamName)
MicroBuildOutputFolderOverride: $(Agent.TempDirectory)/MicroBuild
MicroBuildOutputFolderOverride: ${{ parameters.microBuildOutputFolder }}
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
continueOnError: ${{ parameters.continueOnError }}
condition: and(succeeded(), ne(variables['Agent.Os'], 'Windows_NT'), eq(variables['_SignType'], 'real'))
51 changes: 10 additions & 41 deletions src/Microsoft.DotNet.Arcade.Sdk/tools/Sign.proj
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!-- Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the MIT license. -->
<Project DefaultTargets="Sign" InitialTargets="InitializeSignProperties;FindDotNetPathForMicroBuild">
<Project DefaultTargets="Sign">

<!--
Documentation for publishing is available here:
Expand Down Expand Up @@ -43,7 +43,7 @@
<FileSignInfo Update="@(FileSignInfo->WithMetadataValue('CertificateName','Microsoft400'))" CertificateName="$(DotNetCertificateName)" />
</ItemGroup>

<Target Name="InitializeSignProperties">
<Target Name="Sign">
<Error Text="The value of DotNetSignType is invalid: '$(DotNetSignType)'"
Condition="'$(DotNetSignType)' != 'real' and '$(DotNetSignType)' != 'test' and '$(DotNetSignType)' != ''" />

Expand All @@ -55,54 +55,23 @@
<_TestSign>false</_TestSign>
<_TestSign Condition="'$(DotNetSignType)' == 'test'">true</_TestSign>

<_MicroBuildRequired>false</_MicroBuildRequired>
<_MicroBuildRequired Condition="'$(_DryRun)' != 'true'">true</_MicroBuildRequired>
<_DotNetCoreRequired>false</_DotNetCoreRequired>
<_DotNetCoreRequired Condition="'$(_DryRun)' != 'true'">true</_DotNetCoreRequired>

<!-- SN is only available on Windows -->
<SNBinaryPath Condition="$([MSBuild]::IsOSPlatform('Windows'))">$(NuGetPackageRoot)sn\$(SNVersion)\sn.exe</SNBinaryPath>

<!-- .pkgs and .app bundle tooling is only available on MacOS -->
<PkgToolPath Condition="$([MSBuild]::IsOSPlatform('OSX'))">$(NuGetPackageRoot)microsoft.dotnet.macospkg.cli\$(MicrosoftDotNetMacOsPkgVersion)\tools\$(NetToolCurrent)\any\Microsoft.Dotnet.MacOsPkg.Cli.dll</PkgToolPath>
</PropertyGroup>
</Target>

<Target Name="FindDotNetPathForMicroBuild" Condition="'$(_MicroBuildRequired)' == 'true'">
<!--
On non-Windows platforms, MicroBuild needs the .NET 8 SDK for signing.
Non-windows signed (real or test) builds will install this SDK into a */.dotnet-microbuild/* directory
and add it to the PATH.
-->
<PropertyGroup>
<UseDotNetToolPathForMicroBuild>false</UseDotNetToolPathForMicroBuild>
<UseDotNetToolPathForMicroBuild Condition="$([MSBuild]::IsOSPlatform('Windows'))">true</UseDotNetToolPathForMicroBuild>

<!-- Default for Windows. Default fallback for non-windows. -->
<_DotNetPathMicroBuild>$(DotNetTool)</_DotNetPathMicroBuild>
</PropertyGroup>

<ItemGroup Condition="'$(UseDotNetToolPathForMicroBuild)' == 'false'">
<_ItemInPath Include="$([System.Text.RegularExpressions.Regex]::Split('$(PATH)', '$([System.Convert]::ToString($([System.IO.Path]::PathSeparator)))'))" />

<_DotNetPathMicroBuildCandidate
Include="@(_ItemInPath->'%(Identity)/dotnet')"
Condition="$([System.Text.RegularExpressions.Regex]::IsMatch('%(Identity)', '.dotnet-microbuild')) and Exists('%(Identity)/dotnet')" />
</ItemGroup>

<PropertyGroup Condition="'@(_DotNetPathMicroBuildCandidate)' != ''">
<!-- This gets overwritten for each item, so the last one wins -->
<_DotNetPathMicroBuild>%(_DotNetPathMicroBuildCandidate.Identity)</_DotNetPathMicroBuild>
</PropertyGroup>

<Message
Importance="High"
Condition="'$(UseDotNetToolPathForMicroBuild)' == 'false' and '$(_DotNetPathMicroBuild)' == '$(DotNetTool)'"
Text="Did not find a dotnet executable in a MicroBuild directory on PATH. Using $(DotNetTool) instead, which may cause signing errors." />
</Target>

<Target Name="Sign">
<Error Condition="'$(AllowEmptySignList)' != 'true' AND '@(ItemsToSign)' == ''"
Text="List of files to sign is empty. Make sure that ItemsToSign is configured correctly." />

<PropertyGroup Condition="$(_DotNetCoreRequired)">
<_DotNetCorePath>$(DotNetTool)</_DotNetCorePath>
</PropertyGroup>

<!-- Keep TarToolPath TFM in sync with TarTool project TFM. -->
<Microsoft.DotNet.SignTool.SignToolTask
DryRun="$(_DryRun)"
Expand All @@ -117,8 +86,7 @@
FileExtensionSignInfo="@(FileExtensionSignInfo)"
TempDir="$(ArtifactsTmpDir)"
LogDir="$(ArtifactsLogDir)"
DotNetPathMicroBuild="$(_DotNetPathMicroBuild)"
DotNetPathTooling="$(DotNetTool)"
DotNetPath="$(_DotNetCorePath)"
SNBinaryPath="$(SNBinaryPath)"
MicroBuildCorePath="$(NuGetPackageRoot)microsoft.visualstudioeng.microbuild.core\$(MicrosoftVisualStudioEngMicroBuildCoreVersion)"
Wix3ToolsPath="$(WixInstallPath)"
Expand All @@ -130,4 +98,5 @@
DotNetTimeout="$(SignToolDotNetTimeout)"
MSBuildVerbosity="$(SignToolMSBuildVerbosity)" />
</Target>

</Project>
20 changes: 0 additions & 20 deletions src/Microsoft.DotNet.SignTool.Tests/Config.cs

This file was deleted.

6 changes: 1 addition & 5 deletions src/Microsoft.DotNet.SignTool.Tests/FakeSignTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,6 @@ private static void SignPEFile(string path)

public override SigningStatus VerifySignedVSIX(string filePath) => SigningStatus.Signed;

public override SigningStatus VerifySignedPkgOrAppBundle(
TaskLoggingHelper log,
string filePath,
string dotNetPathTooling,
string pkgToolPath) => SigningStatus.Signed;
public override SigningStatus VerifySignedPkgOrAppBundle(TaskLoggingHelper log, string filePath, string pkgToolPath) => SigningStatus.Signed;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,4 @@
<Content Include="@(_PkgToolFiles)" CopyToOutputDirectory="PreserveNewest" Link="tools\pkg\%(RecursiveDir)%(Filename)%(Extension)"/>
</ItemGroup>
</Target>

<ItemGroup>
<RuntimeHostConfigurationOption Include="$(MSBuildProjectName).DotNetPathTooling">
<Value>$(DotNetTool)</Value>
</RuntimeHostConfigurationOption>
</ItemGroup>
</Project>
Loading
Loading