File: Microsoft.NET.Sdk.Web.Tasks.csproj
Web Access
Project: ..\..\..\src\WebSdk\Web\Tasks\Microsoft.NET.Sdk.Web.Tasks.csproj (Microsoft.NET.Sdk.Web.Tasks)
<Project>
 
  <PropertyGroup>
    <WebRoot Condition="'$(WebRoot)' == ''">$(RepoRoot)\src\WebSdk\Web\</WebRoot>
    <PackageId>Microsoft.NET.Sdk.Web</PackageId>
    <OutDirName>$(Configuration)\Sdks\$(PackageId)\tools</OutDirName>
  </PropertyGroup>
 
  <Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" />
  <Import Project="$(RepoRoot)\src\WebSdk\Package.props" />
 
  <PropertyGroup>
    <TargetFrameworks>$(SdkTargetFramework);net472</TargetFrameworks>
 
    <!--
      Disable CS9057 in source-only dev/ci builds. This is necessary because the SDK distributes Microsoft.AspNetCore.Analyzers
      with its Microsoft.NET.Sdk.Web.Tasks package. Microsoft.AspNetCore.Analyzers gets built with a dependency on the live
      version of Microsoft.CodeAnalysis. In a dev/ci build, the assembly version associated with Microsoft.CodeAnalysis in 
      that case is 42.42.42.4242, set by Arcade in dev/ci builds. So when building Microsoft.NET.Sdk.Web.Tasks with its
      analyzer dependencies, it will cause CS9057 because the analyzer assembly version is not the same as the compiler
      assembly version being used by the sdk that the project is being built with. But this is fine because the analyzer
      is just being used here to distribute it with the Microsoft.NET.Sdk.Web.Tasks package.
    -->
    <NoWarn Condition="'$(DotNetBuildSourceOnly)' == 'true' and '$(OfficialBuild)' != 'true'">$(NoWarn);CS9057</NoWarn>
  </PropertyGroup>
 
  <ItemGroup>
    <AdditionalContent Include="$(WebRoot)\Targets\**\*.*">
      <Pack>true</Pack>
      <PackagePath>Targets</PackagePath>
    </AdditionalContent>
 
    <AdditionalContent Include="$(WebRoot)\Sdk\**\*.*">
      <Pack>true</Pack>
      <PackagePath>Sdk</PackagePath>
    </AdditionalContent>
  </ItemGroup>
 
  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.Analyzers" VersionOverride="$(MicrosoftAspNetCoreAnalyzersPackageVersion)" PrivateAssets="All" BundleAsAnalyzer="true" />
    <PackageReference Include="Microsoft.AspNetCore.Components.SdkAnalyzers" VersionOverride="$(MicrosoftAspNetCoreComponentsSdkAnalyzersPackageVersion)" PrivateAssets="All" BundleAsAnalyzer="true" />
    <PackageReference Include="Microsoft.AspNetCore.Mvc.Analyzers" VersionOverride="$(MicrosoftAspNetCoreMvcAnalyzersPackageVersion)" PrivateAssets="All" BundleAsAnalyzer="true" />
    <PackageReference Include="Microsoft.AspNetCore.Mvc.Api.Analyzers" VersionOverride="$(MicrosoftAspNetCoreMvcApiAnalyzersPackageVersion)" PrivateAssets="All" BundleAsAnalyzer="true" />
  </ItemGroup>
 
  <Target Name="_PackBundledAnalyzers" Inputs="@(PackageReference-&gt;HasMetadata('BundleAsAnalyzer'))" Outputs="%(PackageReference.Identity)" BeforeTargets="Build">
    <PropertyGroup>
      <_AnalyzerPath>$(NuGetPackageRoot)@(PackageReference-&gt;ToLower())\@(PackageReference-&gt;Metadata('VersionOverride')-&gt;ToLower())\analyzers\</_AnalyzerPath>
    </PropertyGroup>
    <ItemGroup>
      <_AnalyzerFile Include="$(_AnalyzerPath)**\*.dll" />
    </ItemGroup>
 
    <Error Text="No files found for analyzer for @(PackageReference) at path $(_AnalyzerPath)" Condition="'@(_AnalyzerFile-&gt;Count())' == '0'" />
 
    <ItemGroup>
      <AdditionalContent Include="@(_AnalyzerFile)" Pack="true" PackagePath="analyzers/cs" />
    </ItemGroup>
  </Target>
 
  <Import Project="$(RepoRoot)\src\WebSdk\CopyPackageLayout.targets" />
  <Import Project="Sdk.targets" Sdk="Microsoft.NET.Sdk" />
 
</Project>