File: Microsoft.DotNet.MSBuildSdkResolver.csproj
Web Access
Project: ..\..\..\src\Resolvers\Microsoft.DotNet.MSBuildSdkResolver\Microsoft.DotNet.MSBuildSdkResolver.csproj (Microsoft.DotNet.MSBuildSdkResolver)
<Project Sdk="Microsoft.NET.Sdk">
 
  <PropertyGroup>
    <!-- The version is frozen to allow MSBuild.exe loading it into the default load context -->
    <AssemblyVersion>8.0.100.0</AssemblyVersion>
    <TargetFramework>net472</TargetFramework>
    <StrongNameKeyId>MicrosoftAspNetCore</StrongNameKeyId>
    <!-- Create FileDefinitions items for ResolveHostfxrCopyLocalContent target -->
    <EmitLegacyAssetsFileItems>true</EmitLegacyAssetsFileItems>
    <!-- For product build, this project only builds in the second build pass as it depends on assets from other
         verticals that are built in the first build pass. -->
    <ExcludeFromDotNetBuild Condition="'$(DotNetBuild)' == 'true' and '$(DotNetBuildPass)' != '2'">true</ExcludeFromDotNetBuild>
  </PropertyGroup>
 
  <ItemGroup>
    <EmbeddedResource Include="..\Microsoft.NET.Sdk.WorkloadManifestReader\Strings.resx" LinkBase="Resources" GenerateSource="True" Namespace="Microsoft.NET.Sdk.Localization" />
  </ItemGroup>
 
  <!-- We need to use relative path due to if we want to run tests in helix. Since we would need to run the tests in a different helix machine
       and the absolute path will not work on a different machine. We also made sure the relative file structure is preserved on helix machines.-->
  <Target Name="WriteFullFrameworkResolverManifest" AfterTargets="AfterBuild" Condition="'$(ExcludeFromDotNetBuild)' != 'true'">
    <PropertyGroup>
      <_ResolverManifestDir>$(OutputPath)\SdkResolvers\$(AssemblyName)\</_ResolverManifestDir>
      <_TargetPathRelativePath>..\..\$(TargetFileName)</_TargetPathRelativePath>
    </PropertyGroup>
 
    <!-- Path.GetRelativePath doesn't exist on full framework. So we hard-code the relative path, and then if we're running on .NET, we check
         to make sure the value we hard-coded is the same as we would get by calling Path.GetRelativePath -->
    <PropertyGroup Condition=" '$(MSBuildRuntimeType)' == 'Core'">
      <_TargetPathRelativePathCheck>$([System.IO.Path]::GetRelativePath('$(_ResolverManifestDir)','$(TargetPath)'))</_TargetPathRelativePathCheck>
    </PropertyGroup>
 
    <Error Condition=" '$(MSBuildRuntimeType)' == 'Core' And '$(_TargetPathRelativePath)' != '$(_TargetPathRelativePathCheck)'"
           Text="Incorrect relative path calculation" />
 
    <ItemGroup>
      <ManifestLines Include="&lt;SdkResolver&gt;" />
      <ManifestLines Include="&lt;Path&gt;$(_TargetPathRelativePath)&lt;/Path&gt;" />
      <ManifestLines Include="&lt;/SdkResolver&gt;" />
    </ItemGroup>
 
    <WriteLinesToFile File="$(_ResolverManifestDir)$(AssemblyName).xml" Lines="@(ManifestLines)" Overwrite="true" WriteOnlyWhenDifferent="true" />
  </Target>
 
  <ItemGroup>
    <EmbeddedResource Update="**\*.resx" GenerateSource="true" />
  </ItemGroup>
 
  <!-- To reduce dll load (cause RPS perf regression). Directly compile files from Microsoft.DotNet.NativeWrapper, Microsoft.DotNet.SdkResolver, and the workload resolver -->
  <ItemGroup>
    <Compile Include="$(RepoRoot)src\Cli\dotnet\Commands\Workload\InstallStateContents.cs" LinkBase="Cli" />
    <Compile Include="..\Microsoft.DotNet.NativeWrapper\**\*.cs" LinkBase="Microsoft.DotNet.NativeWrapper" />
    <Compile Include="..\Microsoft.DotNet.SdkResolver\**\*.cs" LinkBase="Microsoft.DotNet.SdkResolver" />
    <Compile Include="..\Microsoft.NET.Sdk.WorkloadMSBuildSdkResolver\CachingWorkloadResolver.cs" LinkBase="Microsoft.NET.Sdk.WorkloadMSBuildSdkResolver" />
    <Compile Include="..\Microsoft.NET.Sdk.WorkloadManifestReader\**\*.cs" LinkBase="Microsoft.NET.Sdk.WorkloadManifestReader" />
    <Compile Include="..\..\Cli\dotnet\Commands\Workload\Install\WorkloadInstallRecords\**\*.cs"
             Exclude="..\..\Cli\dotnet\Commands\Workload\Install\WorkloadInstallRecords\RegistryWorkloadInstallationRecordRepository.cs"
             LinkBase="WorkloadInstallRecords" />
 
    <Compile Include="$(RepoRoot)src\Common\EnvironmentVariableNames.cs" LinkBase="Common" />
    <Compile Include="$(RepoRoot)src\Common\CliFolderPathCalculatorCore.cs" LinkBase="Common" />
    <Compile Include="$(RepoRoot)src\Common\Polyfills.cs" LinkBase="Common" />
    <Compile Include="$(RepoRoot)src\Common\WorkloadFileBasedInstall.cs" LinkBase="Common" />
    <Compile Include="$(RepoRoot)src\Common\WorkloadSetVersion.cs" LinkBase="Common" />
  </ItemGroup>
 
  <ItemGroup>
    <!-- Netfx version builds against the lowest version of these dependencies that's guaranteed to be shipped with MSBuild in VS -->
    <PackageReference Include="Microsoft.Bcl.AsyncInterfaces" VersionOverride="$(MicrosoftBclAsyncInterfacesToolsetPackageVersion)" />
    <PackageReference Include="Microsoft.Build.Framework" PrivateAssets="All" />
    <PackageReference Include="Microsoft.Deployment.DotNet.Releases" VersionOverride="$(MicrosoftDeploymentDotNetReleasesToolsetPackageVersion)" />
    <PackageReference Include="System.Collections.Immutable" VersionOverride="$(SystemCollectionsImmutableToolsetPackageVersion)" />
    <PackageReference Include="System.Text.Json" VersionOverride="$(SystemTextJsonToolsetPackageVersion)" />
    <PackageReference Include="System.Diagnostics.DiagnosticSource" VersionOverride="$(SystemDiagnosticsDiagnosticSourceToolsetPackageVersion)" />
    <PackageReference Include="Microsoft.VisualStudio.Setup.Configuration.Interop" PrivateAssets="All" ExcludeAssets="Runtime" />
  </ItemGroup>
 
  <ItemGroup>
    <PackageDownload Include="Microsoft.NETCore.App.Runtime.win-x86" Version="[$(MicrosoftNETCoreAppRuntimePackageVersion)]" />
    <PackageDownload Include="Microsoft.NETCore.App.Runtime.win-x64" Version="[$(MicrosoftNETCoreAppRuntimePackageVersion)]" />
    <PackageDownload Include="Microsoft.NETCore.App.Runtime.win-arm64" Version="[$(MicrosoftNETCoreAppRuntimePackageVersion)]" />
 
    <Content Include="$(NuGetPackageRoot)/microsoft.netcore.app.runtime.win-x86/$(MicrosoftNETCoreAppRuntimePackageVersion)/runtimes/win-x86/native/hostfxr.dll"
             Link="x86/hostfxr.dll"
             CopyToOutputDirectory="PreserveNewest" />
    <Content Include="$(NuGetPackageRoot)/microsoft.netcore.app.runtime.win-x64/$(MicrosoftNETCoreAppRuntimePackageVersion)/runtimes/win-x64/native/hostfxr.dll"
             Link="x64/hostfxr.dll"
             CopyToOutputDirectory="PreserveNewest" />
    <Content Include="$(NuGetPackageRoot)/microsoft.netcore.app.runtime.win-arm64/$(MicrosoftNETCoreAppRuntimePackageVersion)/runtimes/win-arm64/native/hostfxr.dll"
             Link="arm64/hostfxr.dll"
             CopyToOutputDirectory="PreserveNewest" />
  </ItemGroup>
 
  <Target Name="LinkVSEmbeddableAssemblies" AfterTargets="ResolveReferences" Condition="'$(ExcludeFromDotNetBuild)' != 'true'">
    <ItemGroup>
      <ReferencePath Condition="'%(ReferencePath.FileName)' == 'Microsoft.VisualStudio.Setup.Configuration.Interop'">
        <EmbedInteropTypes>true</EmbedInteropTypes>
      </ReferencePath>
    </ItemGroup>
  </Target>
 
  <Target Name="VerifyDependencies" AfterTargets="Build" Condition="'$(ExcludeFromDotNetBuild)' != 'true'">
    <ResolveAssemblyReference AssemblyFiles="$(TargetPath)" SearchPaths="" AutoUnify="true">
      <Output TaskParameter="ResolvedDependencyFiles" ItemName="ResolvedDependencies" />
    </ResolveAssemblyReference>
 
    <!-- Define the expected dependencies of the output assembly.
         IMPORTANT: When modifying this list, coordinate with the MSBuild team to ensure:
         1. Each dependency has a corresponding binding redirect in MSBuild.exe.
         2. Dependency version fall within the ranges specified in MSBuild.exe binding redirects.
         Note: Verify versions against the binding redirects of the minimum supported MSBuild version, located at: src/Layout/redist/minimumMSBuildVersion
         You can find the MSBuild.exe binding redirects here: https://github.com/dotnet/msbuild/blob/<msbuild version branch>/src/MSBuild/app.amd64.config  -->
    <ItemGroup>
      <ExpectedDependencies Include="Microsoft.Deployment.DotNet.Releases, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
      <ExpectedDependencies Include="System.Text.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" />
      <ExpectedDependencies Include="System.Text.Encodings.Web, Version=9.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" />
      <ExpectedDependencies Include="Microsoft.Build.Framework, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
      <ExpectedDependencies Include="System.Collections.Immutable, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
      <ExpectedDependencies Include="System.IO.Pipelines, Version=9.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" />
      <ExpectedDependencies Include="System.Memory, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" />
      <ExpectedDependencies Include="Microsoft.Bcl.AsyncInterfaces, Version=9.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" />
      <ExpectedDependencies Include="System.Runtime.CompilerServices.Unsafe, Version=6.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
      <ExpectedDependencies Include="System.Numerics.Vectors, Version=4.1.5.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
      <ExpectedDependencies Include="System.Buffers, Version=4.0.4.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" />
      <ExpectedDependencies Include="System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" />
      <ExpectedDependencies Include="System.Diagnostics.DiagnosticSource, Version=9.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" />
    </ItemGroup>
 
    <!-- Check that the dependencies of the output assembly match our expectations -->
    <PropertyGroup>
      <ResolvedDependenciesList>@(ResolvedDependencies->'%(FusionName)')</ResolvedDependenciesList>
      <ExpectedDependenciesList>@(ExpectedDependencies->'%(Identity)')</ExpectedDependenciesList>
      <DependencyMismatchErrorText>This may have consequences for MSBuild.exe binding redirects, please get signoff from the MSBuild team.</DependencyMismatchErrorText>
    </PropertyGroup>
 
    <Error Text="$(AssemblyName) is expected to depend on %(ExpectedDependencies.Identity). $(DependencyMismatchErrorText)"
           Condition="!($([System.String]::Copy('$(ResolvedDependenciesList)').Contains('%(ExpectedDependencies.Identity)')))"
           ContinueOnError="true" />
    <Error Text="$(AssemblyName) is not expected to depend on %(ResolvedDependencies.FusionName). $(DependencyMismatchErrorText)"
           Condition="!($([System.String]::Copy('$(ExpectedDependenciesList)').Contains('%(ResolvedDependencies.FusionName)')))"
           ContinueOnError="true" />
  </Target>
 
</Project>