Skip to content
Draft
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
53 changes: 53 additions & 0 deletions eng/SDKDeliveredMSBuildTask.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<!-- Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the MIT license. See License.txt in the project root for full license information. -->
<Project>

<!-- Common configuration for MSBuild task assemblies that ship in the SDK. -->

<PropertyGroup>
<OutputType>Library</OutputType>
<TargetFrameworks>$(SdkTargetFramework);net472</TargetFrameworks>

<!-- MSBuild Task DLLs need to be versioned with every build -->
<AutoGenerateAssemblyVersion>true</AutoGenerateAssemblyVersion>

<!-- Avoid https://github.com/dotnet/arcade/issues/9305 -->
<AutoGenerateBindingRedirects>false</AutoGenerateBindingRedirects>

<!-- SDK tasks can reliably use the assemblies found in the SDK so don't need a deps file -->
<GenerateDependencyFile>false</GenerateDependencyFile>
</PropertyGroup>

<!-- MSBuild core references -->
<ItemGroup>
<PackageReference Include="Microsoft.Build" ExcludeAssets="Runtime" /><!-- Not needed by most tasks but a couple of APIs are used. -->
<PackageReference Include="Microsoft.Build.Framework" ExcludeAssets="Runtime" />
<PackageReference Include="Microsoft.Build.Utilities.Core" ExcludeAssets="Runtime" />
</ItemGroup>

<!--
These packages use VersionOverride to ensure compatibility with MSBuild's binding redirects.
To be compatible with .NET Framework MSBuild, dependencies that are shared with MSBuild must
either:

1. Be within the MSBuild binding redirects, so the assemblies are fully provided by MSBuild
and don't need to be redistributed or have all references be to the same version, OR
2. Be redistributed alongside the SDK task assemblies, and avoid the need for binding
redirects within closure of the task (i.e. ALL assembly versions referenced must
always exactly match).

For .NET SDK tasks we prefer option 1.

See MSBuild binding redirect configuration for the relevant version:
https://github.com/dotnet/msbuild/blob/main/src/MSBuild/app.config
-->

<ItemGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework'">
<PackageReference Include="System.Collections.Immutable" VersionOverride="$(SystemCollectionsImmutableToolsetPackageVersion)" />
<PackageReference Include="System.Diagnostics.DiagnosticSource" VersionOverride="$(SystemDiagnosticsDiagnosticSourceToolsetPackageVersion)" />
<PackageReference Include="System.Reflection.Metadata" VersionOverride="$(SystemReflectionMetadataToolsetPackageVersion)" />
<PackageReference Include="System.Reflection.MetadataLoadContext" VersionOverride="$(SystemReflectionMetadataLoadContextToolsetPackageVersion)" />
<PackageReference Include="System.Resources.Extensions" VersionOverride="$(SystemResourcesExtensionsToolsetPackageVersion)" />
<PackageReference Include="System.Text.Json" VersionOverride="$(SystemTextJsonToolsetPackageVersion)" />
</ItemGroup>

</Project>
14 changes: 1 addition & 13 deletions src/RazorSdk/Tasks/Microsoft.NET.Sdk.Razor.Tasks.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,16 @@
</PropertyGroup>

<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" />
<Import Project="$(RepositoryEngineeringDir)SDKDeliveredMSBuildTask.props" />

<PropertyGroup>
<OutputType>Library</OutputType>

<EnableDefaultItems>false</EnableDefaultItems>
<GenerateDependencyFile>false</GenerateDependencyFile>
<IncludeBuildOutput>false</IncludeBuildOutput>

<NoPackageAnalysis>true</NoPackageAnalysis>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>

<CopyLocalLockFileAssemblies Condition="'$(TargetFramework)'!='net472'">false</CopyLocalLockFileAssemblies>
<!-- MSBuild Task DLLs need to be versioned with every build -->
<AutoGenerateAssemblyVersion>true</AutoGenerateAssemblyVersion>

<OutputPath>$(BaseOutputPath)</OutputPath>
<IsPackable>true</IsPackable>
Expand All @@ -35,20 +31,12 @@
<Description>SDK for building and publishing Razor applications.</Description>
<OutputType>Library</OutputType>
<RootNamespace>Microsoft.NET.Sdk.Razor</RootNamespace>
<TargetFrameworks>$(SdkTargetFramework);net472</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Build.Framework" ExcludeAssets="Runtime" />
<PackageReference Include="Microsoft.Build.Utilities.Core" ExcludeAssets="Runtime" />
<PackageReference Include="Microsoft.Extensions.FileSystemGlobbing" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework'">
<PackageReference Include="System.Reflection.Metadata" VersionOverride="$(SystemReflectionMetadataToolsetPackageVersion)" />
<PackageReference Include="System.Text.Json" VersionOverride="$(SystemTextJsonToolsetPackageVersion)" />
</ItemGroup>

<ItemGroup>
<AdditionalContent Include="$(RazorSdkRoot)Targets\**\*.*">
<Pack>true</Pack>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,18 @@
</PropertyGroup>

<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" />
<Import Project="$(RepositoryEngineeringDir)SDKDeliveredMSBuildTask.props" />

<PropertyGroup>
<TargetFrameworks>$(SdkTargetFramework);net472</TargetFrameworks>
<OutputType>Library</OutputType>
<Description>SDK for building and publishing applications containing static web assets.</Description>
<RootNamespace>Microsoft.NET.Sdk.StaticWebAssets</RootNamespace>

<GenerateDependencyFile>false</GenerateDependencyFile>
<IncludeBuildOutput>false</IncludeBuildOutput>

<NoPackageAnalysis>true</NoPackageAnalysis>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>

<CopyLocalLockFileAssemblies Condition="'$(TargetFramework)'!='net472'">false</CopyLocalLockFileAssemblies>
<!-- MSBuild Task DLLs need to be versioned with every build -->
<AutoGenerateAssemblyVersion>true</AutoGenerateAssemblyVersion>

<OutputPath>$(BaseOutputPath)</OutputPath>
<IsPackable>true</IsPackable>
Expand All @@ -35,8 +31,6 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Build.Framework" ExcludeAssets="Runtime" />
<PackageReference Include="Microsoft.Build.Utilities.Core" ExcludeAssets="Runtime" />
<PackageReference Include="Microsoft.Extensions.FileSystemGlobbing" />
<PackageReference Include="Microsoft.Css.Parser" />
</ItemGroup>
Expand All @@ -46,12 +40,6 @@
<InternalsVisibleTo Include="Microsoft.NET.Sdk.StaticWebAssets.Tests" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework'">
<PackageReference Include="System.Reflection.Metadata" VersionOverride="$(SystemReflectionMetadataToolsetPackageVersion)" />
<PackageReference Include="System.Text.Json" VersionOverride="$(SystemTextJsonToolsetPackageVersion)" />
<PackageReference Include="System.Diagnostics.DiagnosticSource" VersionOverride="$(SystemDiagnosticsDiagnosticSourceToolsetPackageVersion)" />
</ItemGroup>

<!-- Only include these files in the outer build to avoid double writes. -->
<ItemGroup Condition="'$(IsCrossTargetingBuild)' == 'true'">
<AdditionalContent Include="$(StaticWebAssetsSdkRoot)Targets\**\*.*" Pack="true" PackagePath="targets" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
</PropertyGroup>

<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" />
<Import Project="$(RepositoryEngineeringDir)SDKDeliveredMSBuildTask.props" />

<PropertyGroup>
<Description>The MSBuild targets and properties for building .NET Core projects.</Description>
Expand All @@ -17,19 +18,13 @@
<PropertyGroup>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<EnableDefaultItems>false</EnableDefaultItems>
<GenerateDependencyFile>false</GenerateDependencyFile>
<IncludeBuildOutput>false</IncludeBuildOutput>

<!-- only copy symbols from project references (omit xml docs and config files) -->
<AllowedReferenceRelatedFileExtensions>.pdb</AllowedReferenceRelatedFileExtensions>

<NoPackageAnalysis>true</NoPackageAnalysis>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<!-- MSBuild Task DLLs need to be versioned with every build -->
<AutoGenerateAssemblyVersion>true</AutoGenerateAssemblyVersion>

<!-- Avoid https://github.com/dotnet/arcade/issues/9305 -->
<AutoGenerateBindingRedirects>false</AutoGenerateBindingRedirects>
</PropertyGroup>


Expand All @@ -50,9 +45,6 @@
</ItemDefinitionGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Build" ExcludeAssets="Runtime" />
<PackageReference Include="Microsoft.Build.Framework" ExcludeAssets="Runtime" />
<PackageReference Include="Microsoft.Build.Utilities.Core" ExcludeAssets="Runtime" />
<PackageReference Include="Microsoft.Extensions.DependencyModel" />
<PackageReference Include="Microsoft.NET.HostModel" />
<PackageReference Include="NuGet.ProjectModel" />
Expand All @@ -71,18 +63,7 @@

<!-- Packages that are in-box for .NET Core, so we only need to reference them for .NET Framework -->
<ItemGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework'">
<PackageReference Include="System.Text.Json" />
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" />

<!--
Microsoft.NET.HostModel also uses System.Reflection.Metadata. Don't move ahead of the version of System.Reflection.Metadata
that MSBuild supports with the binding redirect to ensure that both this project and Microsoft.NET.HostModel can load
the same System.Reflection.Metadata assembly and their types can unify. See the following link for the MSBuild binding redirect config.
https://github.com/dotnet/msbuild/blob/299e0514835a1588e6ef21b1da748462dec706b8/src/MSBuild/app.config#L60
-->
<PackageReference Include="System.Collections.Immutable" VersionOverride="$(SystemCollectionsImmutableToolsetPackageVersion)" />
<PackageReference Include="System.Reflection.Metadata" VersionOverride="$(SystemReflectionMetadataToolsetPackageVersion)" />
<PackageReference Include="System.Reflection.MetadataLoadContext" VersionOverride="$(SystemReflectionMetadataLoadContextToolsetPackageVersion)" />
</ItemGroup>

<!-- These are loaded from the CLI's copy on .NET Core, we don't need to duplicate them on disk -->
Expand Down
9 changes: 1 addition & 8 deletions src/Tasks/sdk-tasks/sdk-tasks.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="$(RepositoryEngineeringDir)SDKDeliveredMSBuildTask.props" />

<PropertyGroup>
<TargetFrameworks>$(SdkTargetFramework);net472</TargetFrameworks>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
Expand All @@ -12,20 +12,13 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Build" />
<PackageReference Include="Microsoft.Build.Tasks.Core" />
<PackageReference Include="Microsoft.Build.Utilities.Core" />
<PackageReference Include="Microsoft.Deployment.DotNet.Releases" />
<PackageReference Include="Newtonsoft.Json" />
<PackageReference Include="NuGet.Packaging" />
<PackageReference Include="NuGet.Versioning" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework'">
<PackageReference Include="System.Collections.Immutable" VersionOverride="$(SystemCollectionsImmutableToolsetPackageVersion)" />
<PackageReference Include="System.Reflection.Metadata" VersionOverride="$(SystemReflectionMetadataToolsetPackageVersion)" />
<PackageReference Include="System.Reflection.MetadataLoadContext" VersionOverride="$(SystemReflectionMetadataLoadContextToolsetPackageVersion)" />
<PackageReference Include="System.Resources.Extensions" VersionOverride="$(SystemResourcesExtensionsToolsetPackageVersion)" />
<Reference Include="System.Net.Http" />
</ItemGroup>

Expand Down
8 changes: 7 additions & 1 deletion test/sdk-tasks.Tests/sdk-tasks.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,14 @@
</PropertyGroup>

<ItemGroup>
<!-- Provide Microsoft.Build.Utilities.Core at test time
(the tests call `Task.Execute` but don't do anything
too interesting so they could use MSBuildLocator but
don't have to.) -->
<PackageReference Include="Microsoft.Build.Utilities.Core" />

<ProjectReference Include="$(RepoRoot)src\Tasks\sdk-tasks\sdk-tasks.csproj" />
<ProjectReference Include="..\Microsoft.NET.TestFramework\Microsoft.NET.TestFramework.csproj" />
</ItemGroup>

</Project>
</Project>
Loading