diff options
Diffstat (limited to '')
| -rw-r--r-- | src/Directory.wixproj.props | 3 | ||||
| -rw-r--r-- | src/Directory.wixproj.targets | 2 | ||||
| -rw-r--r-- | src/internal/SetBuildNumber/Directory.Packages.props.pp | 1 | ||||
| -rw-r--r-- | src/setup/Directory.Build.props | 4 | ||||
| -rw-r--r-- | src/setup/MetadataTask/GenerateMetadata.cs | 113 | ||||
| -rw-r--r-- | src/setup/MetadataTask/Metadata.cs | 78 | ||||
| -rw-r--r-- | src/setup/MetadataTask/MetadataTask.csproj | 14 | ||||
| -rw-r--r-- | src/setup/WixAdditionalTools/WixAdditionalTools.wixproj | 5 | ||||
| -rw-r--r-- | src/setup/setup.cmd | 2 | ||||
| -rw-r--r-- | src/setup/setup.sln | 13 |
10 files changed, 224 insertions, 11 deletions
diff --git a/src/Directory.wixproj.props b/src/Directory.wixproj.props index 73ac652f..1191bd66 100644 --- a/src/Directory.wixproj.props +++ b/src/Directory.wixproj.props | |||
| @@ -3,7 +3,8 @@ | |||
| 3 | 3 | ||
| 4 | <Project> | 4 | <Project> |
| 5 | <PropertyGroup> | 5 | <PropertyGroup> |
| 6 | <!-- TODO: changing the .wixpdb folder does not actually work until issue #6857 is resolved --> | 6 | <!-- TODO: changing the .wixpdb folder does not actually work until issue #6857 is resolved |
| 7 | <PdbOutputDir>$(PdbsFolder)</PdbOutputDir> | 7 | <PdbOutputDir>$(PdbsFolder)</PdbOutputDir> |
| 8 | --> | ||
| 8 | </PropertyGroup> | 9 | </PropertyGroup> |
| 9 | </Project> | 10 | </Project> |
diff --git a/src/Directory.wixproj.targets b/src/Directory.wixproj.targets index bac132ec..c9fb4f5c 100644 --- a/src/Directory.wixproj.targets +++ b/src/Directory.wixproj.targets | |||
| @@ -8,7 +8,7 @@ | |||
| 8 | <PropertyGroup> | 8 | <PropertyGroup> |
| 9 | <DefineConstants> | 9 | <DefineConstants> |
| 10 | $(DefineConstants); | 10 | $(DefineConstants); |
| 11 | SetupVersion=$(FileVersion); | 11 | SetupVersion=$(PackageVersion); |
| 12 | SetupMajorMinorVersion=$(GitBaseVersionMajor).$(GitBaseVersionMinor); | 12 | SetupMajorMinorVersion=$(GitBaseVersionMajor).$(GitBaseVersionMinor); |
| 13 | </DefineConstants> | 13 | </DefineConstants> |
| 14 | </PropertyGroup> | 14 | </PropertyGroup> |
diff --git a/src/internal/SetBuildNumber/Directory.Packages.props.pp b/src/internal/SetBuildNumber/Directory.Packages.props.pp index 91337de7..f910ba53 100644 --- a/src/internal/SetBuildNumber/Directory.Packages.props.pp +++ b/src/internal/SetBuildNumber/Directory.Packages.props.pp | |||
| @@ -47,6 +47,7 @@ | |||
| 47 | <PackageVersion Include="System.Reflection.Metadata" Version="1.6.0" /> | 47 | <PackageVersion Include="System.Reflection.Metadata" Version="1.6.0" /> |
| 48 | <PackageVersion Include="System.Security.Principal.Windows" Version="4.7.0" /> | 48 | <PackageVersion Include="System.Security.Principal.Windows" Version="4.7.0" /> |
| 49 | <PackageVersion Include="System.Text.Encoding.CodePages" Version="4.6.0" /> | 49 | <PackageVersion Include="System.Text.Encoding.CodePages" Version="4.6.0" /> |
| 50 | <PackageVersion Include="System.Text.Json" Version="4.6.0" /> | ||
| 50 | 51 | ||
| 51 | <PackageVersion Include="Microsoft.AspNetCore.Owin" Version="3.1.13" /> | 52 | <PackageVersion Include="Microsoft.AspNetCore.Owin" Version="3.1.13" /> |
| 52 | <PackageVersion Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.3" /> | 53 | <PackageVersion Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.3" /> |
diff --git a/src/setup/Directory.Build.props b/src/setup/Directory.Build.props index cbf8ecc9..df00142d 100644 --- a/src/setup/Directory.Build.props +++ b/src/setup/Directory.Build.props | |||
| @@ -7,8 +7,4 @@ | |||
| 7 | </PropertyGroup> | 7 | </PropertyGroup> |
| 8 | 8 | ||
| 9 | <Import Project="..\Directory.Build.props" /> | 9 | <Import Project="..\Directory.Build.props" /> |
| 10 | |||
| 11 | <PropertyGroup> | ||
| 12 | <PublishRoot>$(OutputPath)publish\</PublishRoot> | ||
| 13 | </PropertyGroup> | ||
| 14 | </Project> | 10 | </Project> |
diff --git a/src/setup/MetadataTask/GenerateMetadata.cs b/src/setup/MetadataTask/GenerateMetadata.cs new file mode 100644 index 00000000..4071c271 --- /dev/null +++ b/src/setup/MetadataTask/GenerateMetadata.cs | |||
| @@ -0,0 +1,113 @@ | |||
| 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. | ||
| 2 | |||
| 3 | namespace WixToolset.Tasks | ||
| 4 | { | ||
| 5 | using System; | ||
| 6 | using System.Collections.Generic; | ||
| 7 | using System.IO; | ||
| 8 | using System.Linq; | ||
| 9 | using System.Security.Cryptography; | ||
| 10 | using System.Text.Json; | ||
| 11 | using System.Text.Json.Serialization; | ||
| 12 | using Microsoft.Build.Framework; | ||
| 13 | using Microsoft.Build.Utilities; | ||
| 14 | using WixToolset.Data; | ||
| 15 | using WixToolset.Data.Symbols; | ||
| 16 | |||
| 17 | public class GenerateMetadata : Task | ||
| 18 | { | ||
| 19 | private static readonly JsonSerializerOptions SerializerOptions = new JsonSerializerOptions | ||
| 20 | { | ||
| 21 | PropertyNamingPolicy = JsonNamingPolicy.CamelCase, | ||
| 22 | IgnoreNullValues = true, | ||
| 23 | WriteIndented = true, | ||
| 24 | Converters = { new JsonStringEnumConverter(JsonNamingPolicy.CamelCase) }, | ||
| 25 | }; | ||
| 26 | |||
| 27 | [Required] | ||
| 28 | public string TargetFile { get; set; } | ||
| 29 | |||
| 30 | [Required] | ||
| 31 | public string WixpdbFile { get; set; } | ||
| 32 | |||
| 33 | public override bool Execute() | ||
| 34 | { | ||
| 35 | var intermediate = Intermediate.Load(this.WixpdbFile); | ||
| 36 | |||
| 37 | var section = intermediate.Sections.Single(); | ||
| 38 | |||
| 39 | if (section.Type != SectionType.Bundle) | ||
| 40 | { | ||
| 41 | return false; | ||
| 42 | } | ||
| 43 | |||
| 44 | (var metadata, var sourceLineNumber) = this.GetBundleMetadata(section); | ||
| 45 | |||
| 46 | if (metadata != null) | ||
| 47 | { | ||
| 48 | this.PopulateFileInfo(metadata); | ||
| 49 | |||
| 50 | this.SaveMetadata(metadata, sourceLineNumber); | ||
| 51 | } | ||
| 52 | |||
| 53 | return true; | ||
| 54 | } | ||
| 55 | |||
| 56 | private (Metadata, SourceLineNumber) GetBundleMetadata(IntermediateSection section) | ||
| 57 | { | ||
| 58 | var bundleSymbol = section.Symbols.OfType<WixBundleSymbol>().Single(); | ||
| 59 | |||
| 60 | var metadata = new Metadata | ||
| 61 | { | ||
| 62 | Type = MetadataType.Burn, | ||
| 63 | Name = bundleSymbol.Name, | ||
| 64 | Version = bundleSymbol.Version, | ||
| 65 | Publisher = bundleSymbol.Manufacturer, | ||
| 66 | Description = "Installation for " + bundleSymbol.Name, | ||
| 67 | SupportUrl = bundleSymbol.HelpUrl, | ||
| 68 | BundleCode = bundleSymbol.BundleId, | ||
| 69 | UpgradeCode = bundleSymbol.UpgradeCode, | ||
| 70 | AboutUrl = bundleSymbol.AboutUrl, | ||
| 71 | Architecture = PlatformToArchitecture(bundleSymbol.Platform), | ||
| 72 | }; | ||
| 73 | |||
| 74 | return (metadata, bundleSymbol.SourceLineNumbers); | ||
| 75 | } | ||
| 76 | |||
| 77 | private void PopulateFileInfo(Metadata metadata) | ||
| 78 | { | ||
| 79 | var fi = new FileInfo(this.TargetFile); | ||
| 80 | |||
| 81 | using (var sha256 = SHA256.Create()) | ||
| 82 | using (var stream = fi.OpenRead()) | ||
| 83 | { | ||
| 84 | var hash = sha256.ComputeHash(stream); | ||
| 85 | |||
| 86 | metadata.File = fi.Name; | ||
| 87 | metadata.Created = fi.CreationTimeUtc.ToString("O"); | ||
| 88 | metadata.Size = fi.Length; | ||
| 89 | metadata.Sha256 = BitConverter.ToString(hash).Replace("-", String.Empty); | ||
| 90 | } | ||
| 91 | } | ||
| 92 | |||
| 93 | private void SaveMetadata(Metadata metadata, SourceLineNumber sourceLineNumber) | ||
| 94 | { | ||
| 95 | var metadataFilePath = Path.ChangeExtension(this.TargetFile, "metadata.json"); | ||
| 96 | |||
| 97 | var json = JsonSerializer.Serialize(metadata, SerializerOptions); | ||
| 98 | |||
| 99 | File.WriteAllText(metadataFilePath, json); | ||
| 100 | } | ||
| 101 | |||
| 102 | private static ArchitectureType PlatformToArchitecture(Platform platform) | ||
| 103 | { | ||
| 104 | switch (platform) | ||
| 105 | { | ||
| 106 | case Platform.X86: return ArchitectureType.X86; | ||
| 107 | case Platform.X64: return ArchitectureType.X86; | ||
| 108 | case Platform.ARM64: return ArchitectureType.X86; | ||
| 109 | default: throw new ArgumentException($"Unknown platform {platform}"); | ||
| 110 | } | ||
| 111 | } | ||
| 112 | } | ||
| 113 | } | ||
diff --git a/src/setup/MetadataTask/Metadata.cs b/src/setup/MetadataTask/Metadata.cs new file mode 100644 index 00000000..139d9240 --- /dev/null +++ b/src/setup/MetadataTask/Metadata.cs | |||
| @@ -0,0 +1,78 @@ | |||
| 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. | ||
| 2 | |||
| 3 | namespace WixToolset.Tasks | ||
| 4 | { | ||
| 5 | public enum MetadataType | ||
| 6 | { | ||
| 7 | Unknown, | ||
| 8 | Burn, | ||
| 9 | Msi, | ||
| 10 | } | ||
| 11 | |||
| 12 | public enum ArchitectureType | ||
| 13 | { | ||
| 14 | Unknown, | ||
| 15 | Arm64, | ||
| 16 | X64, | ||
| 17 | X86, | ||
| 18 | } | ||
| 19 | |||
| 20 | //{ | ||
| 21 | // "id": [PackageSymbolId] | [BundleSymbolId], | ||
| 22 | // "type": "msi" | "burn" | ||
| 23 | // "name": [ProductName] | [BundleName] | ||
| 24 | // "locale": [ProductLanguage] | [BundleLanguage] | ||
| 25 | // "publisher": [Manufacturer] | ||
| 26 | // "aboutUrl": [ARPURLINFOABOUT] | [AboutUrl] | ||
| 27 | // "supportUrl": [ARPHELPLINK] | [SupportUrl] | ||
| 28 | // "description": [ARPCOMMENTS] | "Installation for" + [BundleName] | ||
| 29 | // "license": [ProductLicense] | [BundleLicense] | ||
| 30 | // "architecture": "x86" | "x64" | "arm64" | ||
| 31 | // "size": #### | ||
| 32 | // "sha256": hex, | ||
| 33 | // "file": <filename> | ||
| 34 | // "created": <ISO timestamp> | ||
| 35 | // "productCode": [ProductCode] | ||
| 36 | // "bundleCode": [BundleId] | ||
| 37 | // "upgradeCode": [UpgradeCode] | ||
| 38 | //} | ||
| 39 | |||
| 40 | public class Metadata | ||
| 41 | { | ||
| 42 | public string Id { get; set; } | ||
| 43 | |||
| 44 | public MetadataType Type { get; set; } | ||
| 45 | |||
| 46 | public string Name { get; set; } | ||
| 47 | |||
| 48 | public string Version { get; set; } | ||
| 49 | |||
| 50 | public string Locale { get; set; } | ||
| 51 | |||
| 52 | public string Publisher { get; set; } | ||
| 53 | |||
| 54 | public string AboutUrl { get; set; } | ||
| 55 | |||
| 56 | public string SupportUrl { get; set; } | ||
| 57 | |||
| 58 | public string Description { get; set; } | ||
| 59 | |||
| 60 | public string License { get; set; } | ||
| 61 | |||
| 62 | public ArchitectureType Architecture { get; set; } | ||
| 63 | |||
| 64 | public string File { get; set; } | ||
| 65 | |||
| 66 | public long Size { get; set; } | ||
| 67 | |||
| 68 | public string Sha256 { get; set; } | ||
| 69 | |||
| 70 | public string Created { get; set; } | ||
| 71 | |||
| 72 | public string ProductCode { get; set; } | ||
| 73 | |||
| 74 | public string BundleCode { get; set; } | ||
| 75 | |||
| 76 | public string UpgradeCode { get; set; } | ||
| 77 | } | ||
| 78 | } | ||
diff --git a/src/setup/MetadataTask/MetadataTask.csproj b/src/setup/MetadataTask/MetadataTask.csproj new file mode 100644 index 00000000..2146a591 --- /dev/null +++ b/src/setup/MetadataTask/MetadataTask.csproj | |||
| @@ -0,0 +1,14 @@ | |||
| 1 | <Project Sdk="Microsoft.NET.Sdk"> | ||
| 2 | <PropertyGroup> | ||
| 3 | <TargetFramework>net472</TargetFramework> | ||
| 4 | <DebugType>embedded</DebugType> | ||
| 5 | <!-- https://github.com/Microsoft/msbuild/issues/2360 --> | ||
| 6 | <PlatformTarget>AnyCPU</PlatformTarget> | ||
| 7 | </PropertyGroup> | ||
| 8 | |||
| 9 | <ItemGroup> | ||
| 10 | <PackageReference Include="Microsoft.Build.Tasks.Core" /> | ||
| 11 | <PackageReference Include="System.Text.Json" /> | ||
| 12 | <PackageReference Include="WixToolset.Data" /> | ||
| 13 | </ItemGroup> | ||
| 14 | </Project> | ||
diff --git a/src/setup/WixAdditionalTools/WixAdditionalTools.wixproj b/src/setup/WixAdditionalTools/WixAdditionalTools.wixproj index 2d2347b3..aca83108 100644 --- a/src/setup/WixAdditionalTools/WixAdditionalTools.wixproj +++ b/src/setup/WixAdditionalTools/WixAdditionalTools.wixproj | |||
| @@ -14,4 +14,9 @@ | |||
| 14 | <PackageReference Include="GitInfo" PrivateAssets="All" /> | 14 | <PackageReference Include="GitInfo" PrivateAssets="All" /> |
| 15 | </ItemGroup> | 15 | </ItemGroup> |
| 16 | 16 | ||
| 17 | <UsingTask TaskName="GenerateMetadata" AssemblyFile="$(BaseOutputPath)$(Configuration)\net472\MetadataTask.dll" /> | ||
| 18 | |||
| 19 | <Target Name="GenerateMetadata" AfterTargets="AfterBuild"> | ||
| 20 | <GenerateMetadata TargetFile="$(TargetPath)" WixpdbFile="$(TargetPdbPath)" /> | ||
| 21 | </Target> | ||
| 17 | </Project> | 22 | </Project> |
diff --git a/src/setup/setup.cmd b/src/setup/setup.cmd index 8096792b..8a7b01c9 100644 --- a/src/setup/setup.cmd +++ b/src/setup/setup.cmd | |||
| @@ -17,6 +17,8 @@ | |||
| 17 | @echo Building setup %_C% | 17 | @echo Building setup %_C% |
| 18 | 18 | ||
| 19 | :: Build | 19 | :: Build |
| 20 | msbuild -Restore MetadataTask\MetadataTask.csproj -p:Configuration=%_C% -nologo -m -warnaserror -bl:%_L%\setup_task.binlog || exit /b | ||
| 21 | |||
| 20 | msbuild -Restore setup.sln -p:Configuration=%_C% -nologo -m -warnaserror -bl:%_L%\setup_build.binlog || exit /b | 22 | msbuild -Restore setup.sln -p:Configuration=%_C% -nologo -m -warnaserror -bl:%_L%\setup_build.binlog || exit /b |
| 21 | 23 | ||
| 22 | :: Publish | 24 | :: Publish |
diff --git a/src/setup/setup.sln b/src/setup/setup.sln index 3998623e..1f3c0cd5 100644 --- a/src/setup/setup.sln +++ b/src/setup/setup.sln | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | | 1 | |
| 2 | Microsoft Visual Studio Solution File, Format Version 12.00 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 |
| 3 | # Visual Studio Version 16 | 3 | # Visual Studio Version 17 |
| 4 | VisualStudioVersion = 16.0.30114.105 | 4 | VisualStudioVersion = 17.2.32630.192 |
| 5 | MinimumVisualStudioVersion = 10.0.40219.1 | 5 | MinimumVisualStudioVersion = 10.0.40219.1 |
| 6 | Project("{B7DD6F7E-DEF8-4E67-B5B7-07EF123DB6F0}") = "ThmViewerPackage", "ThmViewerPackage\ThmViewerPackage.wixproj", "{F8C12838-DEC5-4CA5-97A8-DFE2247564C5}" | 6 | Project("{B7DD6F7E-DEF8-4E67-B5B7-07EF123DB6F0}") = "ThmViewerPackage", "ThmViewerPackage\ThmViewerPackage.wixproj", "{F8C12838-DEC5-4CA5-97A8-DFE2247564C5}" |
| 7 | EndProject | 7 | EndProject |
| @@ -12,9 +12,6 @@ Global | |||
| 12 | Debug|Any CPU = Debug|Any CPU | 12 | Debug|Any CPU = Debug|Any CPU |
| 13 | Release|Any CPU = Release|Any CPU | 13 | Release|Any CPU = Release|Any CPU |
| 14 | EndGlobalSection | 14 | EndGlobalSection |
| 15 | GlobalSection(SolutionProperties) = preSolution | ||
| 16 | HideSolutionNode = FALSE | ||
| 17 | EndGlobalSection | ||
| 18 | GlobalSection(ProjectConfigurationPlatforms) = postSolution | 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution |
| 19 | {F8C12838-DEC5-4CA5-97A8-DFE2247564C5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | 16 | {F8C12838-DEC5-4CA5-97A8-DFE2247564C5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU |
| 20 | {F8C12838-DEC5-4CA5-97A8-DFE2247564C5}.Debug|Any CPU.Build.0 = Debug|Any CPU | 17 | {F8C12838-DEC5-4CA5-97A8-DFE2247564C5}.Debug|Any CPU.Build.0 = Debug|Any CPU |
| @@ -25,4 +22,10 @@ Global | |||
| 25 | {59FF3AD3-339A-4048-9F0B-504EE74BC4AF}.Release|Any CPU.ActiveCfg = Release|Any CPU | 22 | {59FF3AD3-339A-4048-9F0B-504EE74BC4AF}.Release|Any CPU.ActiveCfg = Release|Any CPU |
| 26 | {59FF3AD3-339A-4048-9F0B-504EE74BC4AF}.Release|Any CPU.Build.0 = Release|Any CPU | 23 | {59FF3AD3-339A-4048-9F0B-504EE74BC4AF}.Release|Any CPU.Build.0 = Release|Any CPU |
| 27 | EndGlobalSection | 24 | EndGlobalSection |
| 25 | GlobalSection(SolutionProperties) = preSolution | ||
| 26 | HideSolutionNode = FALSE | ||
| 27 | EndGlobalSection | ||
| 28 | GlobalSection(ExtensibilityGlobals) = postSolution | ||
| 29 | SolutionGuid = {1E2BB345-987B-4108-8EB9-10D703F02EFC} | ||
| 30 | EndGlobalSection | ||
| 28 | EndGlobal | 31 | EndGlobal |
