Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit cdbdb8f

Browse files
[release/10.0.1xx] Source code updates from dotnet/arcade (#2791)
Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> Co-authored-by: Matt Mitchell <[email protected]>
1 parent 498fa57 commit cdbdb8f

File tree

17 files changed

+313
-49
lines changed

17 files changed

+313
-49
lines changed

src/arcade/Arcade.slnx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
<Project Path="src/Microsoft.DotNet.Arcade.Sdk/Microsoft.DotNet.Arcade.Sdk.csproj" />
4646
<Project Path="src/Microsoft.DotNet.ArcadeAzureIntegration/Microsoft.DotNet.ArcadeAzureIntegration.csproj" />
4747
<Project Path="src/Microsoft.DotNet.ArcadeLogging/Microsoft.DotNet.ArcadeLogging.csproj" />
48+
<Project Path="src/Microsoft.DotNet.Baselines.Tasks/Microsoft.DotNet.Baselines.Tasks.csproj" />
4849
<Project Path="src/Microsoft.DotNet.Build.Manifest/Microsoft.DotNet.Build.Manifest.csproj" />
4950
<Project Path="src/Microsoft.DotNet.Build.Tasks.Archives/Microsoft.DotNet.Build.Tasks.Archives.csproj" />
5051
<Project Path="src/Microsoft.DotNet.Build.Tasks.Feed/Microsoft.DotNet.Build.Tasks.Feed.csproj" />
@@ -71,7 +72,6 @@
7172
<Project Path="src/Microsoft.DotNet.SourceBuild/tasks/Microsoft.DotNet.SourceBuild.Tasks.csproj" />
7273
<Project Path="src/Microsoft.DotNet.StrongName/Microsoft.DotNet.StrongName.csproj" />
7374
<Project Path="src/Microsoft.DotNet.Tar/Microsoft.DotNet.Tar.csproj" />
74-
<Project Path="src/Microsoft.DotNet.Baselines.Tasks/Microsoft.DotNet.Baselines.Tasks.csproj" />
7575
<Project Path="src/Microsoft.DotNet.XliffTasks/Microsoft.DotNet.XliffTasks.csproj" />
7676
<Project Path="src/Microsoft.DotNet.XUnitAssert/src/Microsoft.DotNet.XUnitAssert.csproj" />
7777
<Project Path="src/Microsoft.DotNet.XUnitConsoleRunner/src/Microsoft.DotNet.XUnitConsoleRunner.csproj" />

src/arcade/eng/Version.Details.props

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ This file should be imported by eng/Versions.props
1414
<!-- dotnet/templating dependencies -->
1515
<MicrosoftTemplateEngineAuthoringTasksPackageVersion>10.0.100-preview.4.25220.1</MicrosoftTemplateEngineAuthoringTasksPackageVersion>
1616
<!-- dotnet/arcade dependencies -->
17-
<MicrosoftDotNetArcadeSdkPackageVersion>10.0.0-beta.25469.2</MicrosoftDotNetArcadeSdkPackageVersion>
18-
<MicrosoftDotNetHelixSdkPackageVersion>10.0.0-beta.25469.2</MicrosoftDotNetHelixSdkPackageVersion>
17+
<MicrosoftDotNetArcadeSdkPackageVersion>10.0.0-beta.25507.1</MicrosoftDotNetArcadeSdkPackageVersion>
18+
<MicrosoftDotNetHelixSdkPackageVersion>10.0.0-beta.25507.1</MicrosoftDotNetHelixSdkPackageVersion>
1919
<!-- dotnet/arcade-services dependencies -->
2020
<MicrosoftDotNetDarcLibPackageVersion>1.1.0-beta.25424.1</MicrosoftDotNetDarcLibPackageVersion>
2121
<MicrosoftDotNetProductConstructionServiceClientPackageVersion>1.1.0-beta.25424.1</MicrosoftDotNetProductConstructionServiceClientPackageVersion>

src/arcade/eng/Version.Details.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@
2020
<Uri>https://github.com/dotnet/templating</Uri>
2121
<Sha>43b5827697e501c442eb75ffff832cd4df2514fe</Sha>
2222
</Dependency>
23-
<Dependency Name="Microsoft.DotNet.Arcade.Sdk" Version="10.0.0-beta.25469.2">
23+
<Dependency Name="Microsoft.DotNet.Arcade.Sdk" Version="10.0.0-beta.25507.1">
2424
<Uri>https://github.com/dotnet/arcade</Uri>
25-
<Sha>6275af47ebda0d394d4a5a401b77bc6f2304204a</Sha>
25+
<Sha>4eaa220ea860cee9fa61df42411bbf79394edd23</Sha>
2626
</Dependency>
27-
<Dependency Name="Microsoft.DotNet.Helix.Sdk" Version="10.0.0-beta.25469.2">
27+
<Dependency Name="Microsoft.DotNet.Helix.Sdk" Version="10.0.0-beta.25507.1">
2828
<Uri>https://github.com/dotnet/arcade</Uri>
29-
<Sha>6275af47ebda0d394d4a5a401b77bc6f2304204a</Sha>
29+
<Sha>4eaa220ea860cee9fa61df42411bbf79394edd23</Sha>
3030
</Dependency>
3131
<Dependency Name="Microsoft.DotNet.ProductConstructionService.Client" Version="1.1.0-beta.25424.1">
3232
<Uri>https://github.com/dotnet/arcade-services</Uri>

src/arcade/global.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
"dotnet": "10.0.100-rc.1.25451.107"
1313
},
1414
"msbuild-sdks": {
15-
"Microsoft.DotNet.Arcade.Sdk": "10.0.0-beta.25469.2",
16-
"Microsoft.DotNet.Helix.Sdk": "10.0.0-beta.25469.2",
15+
"Microsoft.DotNet.Arcade.Sdk": "10.0.0-beta.25507.1",
16+
"Microsoft.DotNet.Helix.Sdk": "10.0.0-beta.25507.1",
1717
"Microsoft.Build.NoTargets": "3.7.0"
1818
}
1919
}

src/arcade/src/Microsoft.DotNet.Build.Tasks.Installers/build/wix5/bundle/bundle.wxs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,15 @@
6161
</BootstrapperApplication>
6262
<?endif?>
6363

64-
<SoftwareTag Regid="microsoft.com" InstallPath="[ProgramFiles6432Folder]dotnet" />
64+
<?if $(var.Platform)=x64?>
65+
<SoftwareTag Regid="microsoft.com" InstallPath="[ProgramFiles64Folder]dotnet" />
66+
<?endif?>
67+
<?if $(var.Platform)=arm64?>
68+
<SoftwareTag Regid="microsoft.com" InstallPath="[ProgramFiles64Folder]dotnet" />
69+
<?endif?>
70+
<?if $(var.Platform)=x86?>
71+
<SoftwareTag Regid="microsoft.com" InstallPath="[ProgramFilesFolder]dotnet" />
72+
<?endif?>
6573

6674
<!-- Variables used solely for localization. -->
6775
<Variable Name="BUNDLEMONIKER" Type="string" Value="$(var.ProductMoniker) ($(var.TargetArchitectureDescription))" bal:Overridable="no" />

src/arcade/src/Microsoft.DotNet.Build.Tasks.Installers/build/wix5/wix.targets

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@
340340
<CandleVariables Include="BuildVersion" Value="$(MsiVersionString)" />
341341
<CandleVariables Include="NugetVersion" Value="$(Version)" />
342342
<CandleVariables Include="InstallerPlatform" Value="$(MsiArch)" />
343-
<CandleVariables Include="Platform" Value="$(MsiArch)" />
343+
<CandleVariables Include="Platform" Value="$(InstallerTargetArchitecture)" />
344344
<CandleVariables Include="TargetArchitectureDescription" Value="$(InstallerTargetArchitecture)$(CrossArchContentsBuildPart)" />
345345
<CandleVariables Include="UpgradeCode" Value="$(UpgradeCode)" />
346346
<CandleVariables Include="MajorUpgradeSchedule" Value="$(MajorUpgradeSchedule)" Condition="'$(MajorUpgradeSchedule)' != ''" />
Binary file not shown.

src/arcade/src/Microsoft.DotNet.SignTool.Tests/SignToolTests.cs

Lines changed: 107 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1281,6 +1281,93 @@ public void SignZipFile()
12811281
});
12821282
}
12831283

1284+
[Fact]
1285+
public void SignArchivesUsingDetachedSignature()
1286+
{
1287+
// List of files to be considered for signing
1288+
var itemsToSign = new List<ItemToSign>()
1289+
{
1290+
new ItemToSign(GetResourcePath("test.zip")),
1291+
new ItemToSign(GetResourcePath("test.tgz")),
1292+
new ItemToSign(GetResourcePath("NestedZip.zip")),
1293+
new ItemToSign(GetResourcePath("InnerZipFile.zip"))
1294+
};
1295+
1296+
var strongNameSignInfo = new Dictionary<string, List<SignInfo>>();
1297+
1298+
// Overriding information
1299+
var explicitCertKeys = new Dictionary<ExplicitCertificateKey, string>()
1300+
{
1301+
{ new ExplicitCertificateKey("test.zip"), "ArchiveCert" },
1302+
{ new ExplicitCertificateKey("test.tgz"), "ArchiveCert" },
1303+
{ new ExplicitCertificateKey("InnerZipFile.zip"), "ArchiveCert" }
1304+
};
1305+
1306+
var additionalCertificateInfo = new Dictionary<string, List<AdditionalCertificateInformation>>()
1307+
{
1308+
{ "ArchiveCert",
1309+
new List<AdditionalCertificateInformation>() {
1310+
new AdditionalCertificateInformation() { GeneratesDetachedSignature = true }
1311+
}
1312+
}
1313+
};
1314+
1315+
ValidateFileSignInfos(itemsToSign, strongNameSignInfo, explicitCertKeys, s_fileExtensionSignInfo, new[]
1316+
{
1317+
"File 'NativeLibrary.dll' Certificate='Microsoft400'",
1318+
"File 'SOS.NETCore.dll' TargetFramework='.NETCoreApp,Version=v1.0' Certificate='Microsoft400'",
1319+
"File 'Nested.NativeLibrary.dll' Certificate='Microsoft400'",
1320+
"File 'Nested.SOS.NETCore.dll' TargetFramework='.NETCoreApp,Version=v1.0' Certificate='Microsoft400'",
1321+
"File 'test.zip' Certificate='ArchiveCert'",
1322+
"File 'test.tgz' Certificate='ArchiveCert'",
1323+
"File 'InnerZipFile.zip' Certificate='ArchiveCert'",
1324+
"File 'Mid.SOS.NETCore.dll' TargetFramework='.NETCoreApp,Version=v1.0' Certificate='Microsoft400'",
1325+
"File 'MidNativeLibrary.dll' Certificate='Microsoft400'",
1326+
"File 'NestedZip.zip'",
1327+
},
1328+
additionalCertificateInfo: additionalCertificateInfo,
1329+
expectedCopyFiles: new[]
1330+
{
1331+
$"{Path.Combine(_tmpDir, "ContainerSigning", "6", "InnerZipFile.zip")} -> {Path.Combine(_tmpDir, "InnerZipFile.zip")}",
1332+
$"{Path.Combine(_tmpDir, "ContainerSigning", "6", "InnerZipFile.zip.sig")} -> {Path.Combine(_tmpDir, "InnerZipFile.zip.sig")}"
1333+
});
1334+
1335+
ValidateGeneratedProject(itemsToSign, strongNameSignInfo, explicitCertKeys, s_fileExtensionSignInfo, new[]
1336+
{
1337+
$@"
1338+
<FilesToSign Include=""{Uri.EscapeDataString(Path.Combine(_tmpDir, "ContainerSigning", "0", "NativeLibrary.dll"))}"">
1339+
<Authenticode>Microsoft400</Authenticode>
1340+
</FilesToSign>
1341+
<FilesToSign Include=""{Uri.EscapeDataString(Path.Combine(_tmpDir, "ContainerSigning", "1", "SOS.NETCore.dll"))}"">
1342+
<Authenticode>Microsoft400</Authenticode>
1343+
</FilesToSign>
1344+
<FilesToSign Include=""{Uri.EscapeDataString(Path.Combine(_tmpDir, "ContainerSigning", "2", "this_is_a_big_folder_name_look/this_is_an_even_more_longer_folder_name/but_this_one_is_ever_longer_than_the_previous_other_two/Nested.NativeLibrary.dll"))}"">
1345+
<Authenticode>Microsoft400</Authenticode>
1346+
</FilesToSign>
1347+
<FilesToSign Include=""{Uri.EscapeDataString(Path.Combine(_tmpDir, "ContainerSigning", "3", "this_is_a_big_folder_name_look/this_is_an_even_more_longer_folder_name/but_this_one_is_ever_longer_than_the_previous_other_two/Nested.SOS.NETCore.dll"))}"">
1348+
<Authenticode>Microsoft400</Authenticode>
1349+
</FilesToSign>
1350+
<FilesToSign Include=""{Uri.EscapeDataString(Path.Combine(_tmpDir, "ContainerSigning", "7", "Mid.SOS.NETCore.dll"))}"">
1351+
<Authenticode>Microsoft400</Authenticode>
1352+
</FilesToSign>
1353+
<FilesToSign Include=""{Uri.EscapeDataString(Path.Combine(_tmpDir, "ContainerSigning", "8", "MidNativeLibrary.dll"))}"">
1354+
<Authenticode>Microsoft400</Authenticode>
1355+
</FilesToSign>
1356+
",
1357+
$@"
1358+
<FilesToSign Include=""{Uri.EscapeDataString(Path.Combine(_tmpDir, "test.zip"))}"">
1359+
<Authenticode>ArchiveCert</Authenticode>
1360+
</FilesToSign>
1361+
<FilesToSign Include=""{Uri.EscapeDataString(Path.Combine(_tmpDir, "test.tgz"))}"">
1362+
<Authenticode>ArchiveCert</Authenticode>
1363+
</FilesToSign>
1364+
<FilesToSign Include=""{Uri.EscapeDataString(Path.Combine(_tmpDir, "ContainerSigning", "6", "InnerZipFile.zip"))}"">
1365+
<Authenticode>ArchiveCert</Authenticode>
1366+
</FilesToSign>
1367+
"
1368+
}, additionalCertificateInfo: additionalCertificateInfo);
1369+
}
1370+
12841371
/// <summary>
12851372
/// Verifies that signing of pkgs can be done on Windows, even though
12861373
/// we will not unpack or repack them.
@@ -2590,6 +2677,11 @@ public void ValidateSignToolTaskParsing()
25902677
}),
25912678
// Signed pe file
25922679
new TaskItem(GetResourcePath("SignedLibrary.dll"), new Dictionary<string, string>
2680+
{
2681+
{ SignToolConstants.CollisionPriorityId, "123" }
2682+
}),
2683+
// Sign a test.zip
2684+
new TaskItem(GetResourcePath("test.zip"), new Dictionary<string, string>
25932685
{
25942686
{ SignToolConstants.CollisionPriorityId, "123" }
25952687
})
@@ -2621,6 +2713,11 @@ public void ValidateSignToolTaskParsing()
26212713
{ "CertificateName", "DualSignCertificate" },
26222714
{ "PublicKeyToken", "31bf3856ad364e35" },
26232715
{ "CollisionPriorityId", "123" }
2716+
}),
2717+
new TaskItem("test.zip", new Dictionary<string, string>
2718+
{
2719+
{ "CertificateName", "DetachedArchiveCert" },
2720+
{ "CollisionPriorityId", "123" }
26242721
})
26252722
};
26262723

@@ -2637,7 +2734,11 @@ public void ValidateSignToolTaskParsing()
26372734
{ "MacCertificate", "MacDeveloperHarden" },
26382735
{ "MacNotarizationAppName", "com.microsoft.dotnet" },
26392736
{ "CollisionPriorityId", "123" }
2640-
})
2737+
}),
2738+
new TaskItem("DetachedArchiveCert", new Dictionary<string, string>
2739+
{
2740+
{ "DetachedSignature", "true" }
2741+
}),
26412742
};
26422743

26432744
var task = new SignToolTask
@@ -2670,7 +2771,11 @@ public void ValidateSignToolTaskParsing()
26702771
"File 'ProjectOne.dll' TargetFramework='.NETCoreApp,Version=v2.1' Certificate='3PartySHA2' StrongName='ArcadeStrongTest'",
26712772
"File 'ProjectOne.dll' TargetFramework='.NETStandard,Version=v2.0' Certificate='OverrideCertificateName' StrongName='ArcadeStrongTest'",
26722773
"File 'ContainerOne.1.0.0.nupkg' Certificate='NuGet'",
2673-
"File 'SignedLibrary.dll' TargetFramework='.NETCoreApp,Version=v2.0' Certificate='DualSignCertificate'"
2774+
"File 'SignedLibrary.dll' TargetFramework='.NETCoreApp,Version=v2.0' Certificate='DualSignCertificate'",
2775+
"File 'SOS.NETCore.dll' TargetFramework='.NETCoreApp,Version=v1.0' Certificate='Microsoft400'",
2776+
"File 'Nested.NativeLibrary.dll' Certificate='Microsoft400'",
2777+
"File 'Nested.SOS.NETCore.dll' TargetFramework='.NETCoreApp,Version=v1.0' Certificate='Microsoft400'",
2778+
"File 'test.zip' Certificate='DetachedArchiveCert'"
26742779
};
26752780
task.ParsedSigningInput.FilesToSign.Select(f => f.ToString()).Should().BeEquivalentTo(expected);
26762781
}

src/arcade/src/Microsoft.DotNet.SignTool/src/AdditionalCertificateInformation.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ public class AdditionalCertificateInformation
2121
/// If the certificate name represents a sign+notarize operation, this is the name of the notarize operation.
2222
/// </summary>
2323
public string MacNotarizationAppName { get; set; }
24+
/// <summary>
25+
/// If true, this certificate should generate detached signatures instead of in-place signing.
26+
/// </summary>
27+
public bool GeneratesDetachedSignature { get; set; }
2428
public string CollisionPriorityId { get; set; }
2529
}
2630
}

src/arcade/src/Microsoft.DotNet.SignTool/src/BatchSignUtil.cs

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -554,16 +554,30 @@ private void VerifyCertificates(TaskLoggingHelper log)
554554
}
555555
else if (fileName.IsZip())
556556
{
557-
if (fileName.SignInfo.Certificate != null)
557+
// Zip files can't be signed without a detached signature. If a certificate is provided but the signature is not detached.
558+
if (!fileName.SignInfo.GeneratesDetachedSignature && fileName.SignInfo.Certificate != null)
558559
{
559-
log.LogError($"Zip {fileName} should not be signed with this certificate: {fileName.SignInfo.Certificate}");
560+
log.LogError($"'{fileName}' may only be signed with a detached signature. '{fileName.SignInfo.Certificate}' does not produce a detached signature");
560561
}
561562

562563
if (fileName.SignInfo.StrongName != null)
563564
{
564565
log.LogError($"Zip {fileName} cannot be strong name signed.");
565566
}
566567
}
568+
else if (fileName.IsTarGZip())
569+
{
570+
// Tar.gz files can't be signed without a detached signature. If a certificate is provided but the signature is not detached.
571+
if (!fileName.SignInfo.GeneratesDetachedSignature && fileName.SignInfo.Certificate != null)
572+
{
573+
log.LogError($"'{fileName}' may only be signed with a detached signature. '{fileName.SignInfo.Certificate}' does not produce a detached signature");
574+
}
575+
576+
if (fileName.SignInfo.StrongName != null)
577+
{
578+
log.LogError($"TarGZip {fileName} cannot be strong name signed.");
579+
}
580+
}
567581
if (fileName.IsExecutableWixContainer())
568582
{
569583
if (isInvalidEmptyCertificate)
@@ -589,7 +603,28 @@ private void VerifyAfterSign(TaskLoggingHelper log, FileSignInfo file)
589603
// No need to check if the file should not have been signed.
590604
if (file.SignInfo.ShouldSign)
591605
{
592-
if (file.IsPEFile())
606+
// For files with detached signatures, verify the .sig file exists
607+
if (file.SignInfo.GeneratesDetachedSignature)
608+
{
609+
string sigFilePath = file.DetachedSignatureFullPath;
610+
if (!File.Exists(sigFilePath))
611+
{
612+
_log.LogError($"Detached signature file {sigFilePath} does not exist for {file.FullPath}");
613+
}
614+
else
615+
{
616+
var fileInfo = new FileInfo(sigFilePath);
617+
if (fileInfo.Length == 0)
618+
{
619+
_log.LogError($"Detached signature file {sigFilePath} is empty.");
620+
}
621+
else
622+
{
623+
_log.LogMessage(MessageImportance.Low, $"Detached signature file {sigFilePath} exists and is non-empty.");
624+
}
625+
}
626+
}
627+
else if (file.IsPEFile())
593628
{
594629
using (var stream = File.OpenRead(file.FullPath))
595630
{

0 commit comments

Comments
 (0)