Skip to content

Commit

Permalink
[release/6.0] Apply source build patches (backport) (#8384)
Browse files Browse the repository at this point in the history
* Build Microsoft.DotNet.Build.Tasks.Workloads for net6.0

* workaround for hardcoded DotNetSharedFrameworkTaskDir

* don't use obsolete managed SHA256 class

* Disable Workloads WiX dependency in source-build

This removes the prebuilt WiX dependency: #8014

The patch is temporary, pending upstream fix and dependency flow.

Co-authored-by: Michael Simons <msimons@microsoft.com>
Co-authored-by: Davis Goodin <dagood@microsoft.com>
  • Loading branch information
3 people authored Feb 14, 2022
1 parent b1d1532 commit 5f2a9f5
Show file tree
Hide file tree
Showing 13 changed files with 25 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net472;netcoreapp3.1</TargetFrameworks>
<TargetFrameworks Condition="'$(DotNetBuildFromSource)' == 'true'">net6.0</TargetFrameworks>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<LangVersion>Latest</LangVersion>
<IsPackable>true</IsPackable>
Expand All @@ -11,6 +12,16 @@
<NoWarn>$(NoWarn);NU5127</NoWarn>
<EnableDefaultNoneItems>false</EnableDefaultNoneItems>
<RootNamespace>Microsoft.DotNet.Build.Tasks.Workloads</RootNamespace>

<!--
Only include WiX-powered features when running a non-from-source build. (For example, the
Microsoft build used to build .NET for Windows.)
This removes a dependency on prebuilt WiX binaries. The purpose of WiX is to produce Windows
installers, and source-build doesn't run on Windows, so excluding WiX while building in
source-build mode to remove the prebuilt dependency has no impact to available .NET features.
-->
<IncludeWiX Condition="'$(DotNetBuildFromSource)' != 'true'">true</IncludeWiX>
</PropertyGroup>

<ItemGroup>
Expand All @@ -19,13 +30,16 @@
<PackageReference Include="Microsoft.Build.Tasks.Core" Version="$(MicrosoftBuildTasksCoreVersion)" />
<PackageReference Include="Microsoft.Build.Framework" Version="$(MicrosoftBuildFrameworkVersion)" />
<PackageReference Include="NuGet.Packaging" Version="$(NuGetVersion)" />
<PackageReference Include="Wix" Version="3.11.2" />
<PackageReference Include="Microsoft.NET.Sdk.WorkloadManifestReader" Version="$(MicrosoftNetSdkWorkloadManifestReaderVersion)" />
<PackageReference Include="System.Text.Json" Version="$(SystemTextJsonVersion)" Condition="'$(TargetFramework)' == 'net472'"/>
<PackageReference Include="System.Text.Json" Version="$(SystemTextJsonVersion)" Condition="'$(TargetFramework)' == 'net472'" />
<PackageReference Include="Microsoft.Deployment.DotNet.Releases" Version="$(MicrosoftDeploymentDotNetReleasesVersion)" />
</ItemGroup>

<ItemGroup>
<ItemGroup Condition="'$(IncludeWiX)' == 'true'">
<PackageReference Include="Wix" Version="3.11.2" />
</ItemGroup>

<ItemGroup Condition="'$(IncludeWiX)' == 'true'">
<Reference Include="$(WixInstallPath)\Microsoft.Deployment.Resources.dll" />
<Reference Include="$(WixInstallPath)\Microsoft.Deployment.Compression.dll" />
<Reference Include="$(WixInstallPath)\Microsoft.Deployment.Compression.Cab.dll" />
Expand All @@ -48,6 +62,10 @@
<EmbeddedResource Remove="obj\**" />
</ItemGroup>

<ItemGroup Condition="'$(IncludeWiX)' != 'true'">
<Compile Remove="**\*.wix.cs" />
</ItemGroup>

<ItemGroup>
<EmbeddedResource Include="Misc\*.*" />
<EmbeddedResource Include="MsiTemplate\*.wxs" />
Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.DotNet.Build.Tasks.Workloads/src/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public static Guid CreateUuid(Guid namespaceUuid, string name)
Buffer.BlockCopy(nameBytes, 0, hashBuffer, 16, nameBytes.Length);
byte[] hash;

using (SHA256 sha256 = new SHA256Managed())
using (SHA256 sha256 = SHA256.Create())
{
hash = sha256.ComputeHash(hashBuffer);
}
Expand Down
3 changes: 3 additions & 0 deletions src/Microsoft.DotNet.SharedFramework.Sdk/sdk/Sdk.props
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
<PropertyGroup Condition="'$(DotNetSharedFrameworkTaskDir)' == ''">
<DotNetSharedFrameworkTaskDir Condition="'$(MSBuildRuntimeType)' == 'core'">$(MSBuildThisFileDirectory)../tools/netcoreapp3.1/</DotNetSharedFrameworkTaskDir>
<DotNetSharedFrameworkTaskDir Condition="'$(MSBuildRuntimeType)' != 'core'">$(MSBuildThisFileDirectory)../tools/net472/</DotNetSharedFrameworkTaskDir>

<!-- Workaround for https://github.com/dotnet/arcade/issues/7413 -->
<DotNetSharedFrameworkTaskDir Condition="'$(MSBuildRuntimeType)' == 'core' and '$(DotNetBuildFromSource)' == 'true'">$(MSBuildThisFileDirectory)../tools/net6.0/</DotNetSharedFrameworkTaskDir>
</PropertyGroup>

<PropertyGroup>
Expand Down

0 comments on commit 5f2a9f5

Please sign in to comment.