File: C\Users\cloudtest\.nuget\packages\microsoft.dotnet.arcade.sdk\9.0.0-beta.24516.2\tools\Workarounds.targets
Project: ..\..\..\src\Package\DevDivPackage\DevDivPackage.csproj (MSBuildFiles)
<!-- Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the MIT license. -->
<Project>
 
  <!-- Workaround for https://github.com/Microsoft/msbuild/issues/1310 -->
  <Target Name="ForceGenerationOfBindingRedirects"
          AfterTargets="ResolveAssemblyReferences"
          BeforeTargets="GenerateBindingRedirects"
          Condition="'$(AutoGenerateBindingRedirects)' == 'true'">
    <PropertyGroup>
      <!-- Needs to be set in a target because it has to be set after the initial evaluation in the common targets -->
      <GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
    </PropertyGroup>
  </Target>
 
  <!--
    WPF temp project sets OutDir, which makes the SDK create an empty directory for it,
    polluting the output dir. Avoid creating these directories.
    https://github.com/dotnet/sdk/issues/1367
  -->
  <PropertyGroup Condition="'$(IsWpfTempProject)' == 'true'">
    <OutDir/>
  </PropertyGroup>
 
  <!--
    Workaround to fix that Visual Studio sometimes uses a special MSBuild evaluation
    mode where all common conditions (e.g., inside ItemGroup) are ignored.
  -->
  <Choose>
    <When Condition=" '$(IsWpfTempProject)' == 'true' and '$(TargetFrameworkIdentifier)' == '.NETFramework' ">
      <ItemGroup>
        <Reference Include="mscorlib" Pack="false" />
      </ItemGroup>
    </When>
  </Choose>
 
  <!--
     Portable PDBs are not included in .nupkg by default. Include them unless the project produces symbol packages.
     Remove this once we migrate to .snupkg. See https://github.com/dotnet/arcade/issues/1959.
   -->
  <PropertyGroup Condition="'$(DebugType)' == 'portable' and '$(IncludeSymbols)' != 'true'">
    <AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
  </PropertyGroup>
 
  <!--
    Workarounds for insufficient support for tools packages by NuGet Pack: https://github.com/NuGet/Home/issues/6321.
 
    Project that produce tools packages use .nuspec file in order to include all the needed dependencies.
    This target translates common msbuild properties to NuSpec properties.
  -->
  <Target Name="InitializeStandardNuspecProperties"
          BeforeTargets="GenerateNuspec"
          DependsOnTargets="_InitializeNuspecRepositoryInformationPropertiesWorkaround"
          Condition="'$(IsPackable)' == 'true'">
 
    <PropertyGroup>
      <PackageId Condition="'$(NuspecPackageId)' != ''">$(NuspecPackageId)</PackageId>
      <PackageProjectUrl Condition="'$(PackageProjectUrl)' == ''">$(RepositoryUrl)</PackageProjectUrl>
    </PropertyGroup>
 
    <Error Text="PackageDescription must be specified" Condition="'$(PackageDescription)' == ''"/>
    <Error Text="PackageProjectUrl must be specified" Condition="'$(PackageProjectUrl)' == ''"/>
    <Error Text="RepositoryUrl must be specified" Condition="'$(RepositoryUrl)' == ''"/>
    <Error Text="RepositoryCommit must be specified" Condition="'$(RepositoryCommit)' == ''"/>
    <Error Text="RepositoryType must be specified" Condition="'$(RepositoryType)' == ''"/>
    <Error Text="Either PackageLicenseExpression or PackageLicenseFile must be specified" Condition="'$(PackageLicenseExpression)' == '' and '$(PackageLicenseFile)' == ''"/>
 
    <PropertyGroup Condition="'$(NuspecFile)' != '' and '$(NuspecProperties)' == ''">
      <_LicenseElement/>
      <_LicenseElement Condition="'$(PackageLicenseExpression)' != ''">
        <license type="expression">$(PackageLicenseExpression)</license>
      </_LicenseElement>
      <_LicenseElement Condition="'$(PackageLicenseFile)' != ''">
        <license type="file">$(PackageLicenseFile)</license>
      </_LicenseElement>
 
      <_LicenseFileElement/>
      <_LicenseFileElement Condition="'$(PackageLicenseFile)' != ''">
        <file src="$(PackageLicenseFullPath)" target="$(PackageLicenseFile)" />
      </_LicenseFileElement>
 
      <_TagsElement/>
      <_TagsElement Condition="'$(PackageTags)' != ''">
        <tags>$(PackageTags.Replace(';', ' '))</tags>
      </_TagsElement>
 
      <_IconUrlElement/>
      <_IconUrlElement Condition="'$(PackageIcon)' == '' and '$(PackageIconUrl)' != ''">
        <iconUrl>$(PackageIconUrl)</iconUrl>
      </_IconUrlElement>
 
      <_IconElement/>
      <_IconElement Condition="'$(PackageIcon)' != ''">
        <icon>$(PackageIcon)</icon>
      </_IconElement>
 
      <_IconFileElement/>
      <_IconFileElement Condition="'$(PackageIcon)' != ''">
        <file src="$(PackageIconFullPath)" target="$(PackageIcon)" />
      </_IconFileElement>
 
      <_ReleaseNotesElement/>
      <_ReleaseNotesElement Condition="'$(PackageReleaseNotes)' != ''">
        <releaseNotes>$(PackageReleaseNotes)</releaseNotes>
      </_ReleaseNotesElement>
 
      <_CommonMetadataElements>
        <id>$(PackageId)</id>
        <description>$(PackageDescription)</description>
        <version>$(PackageVersion)</version>
        <authors>$(Authors)</authors>
        <requireLicenseAcceptance>$(PackageRequireLicenseAcceptance)</requireLicenseAcceptance>
        $(_TagsElement)
        $(_LicenseElement)
        $(_IconElement)
        $(_IconUrlElement)
        $(_ReleaseNotesElement)
        <projectUrl>$(PackageProjectUrl)</projectUrl>
        <copyright>$(Copyright)</copyright>
        <developmentDependency>$(DevelopmentDependency)</developmentDependency>
        <serviceable>$(Serviceable)</serviceable>
        <repository type="$(RepositoryType)" url="$(RepositoryUrl)" commit="$(RepositoryCommit)" />
      </_CommonMetadataElements>
 
      <_CommonFileElements>
        $(_IconFileElement)
        $(_LicenseFileElement)
      </_CommonFileElements>
    </PropertyGroup>
 
    <ItemGroup Condition="'$(NuspecFile)' != '' and '$(NuspecProperties)' == ''">
      <NuspecProperty Include="CommonMetadataElements=$(_CommonMetadataElements)"/>
      <NuspecProperty Include="CommonFileElements=$(_CommonFileElements)"/>
      <NuspecProperty Include="PackageId=$(PackageId)"/>
      <NuspecProperty Include="Version=$(PackageVersion)"/>
      <NuspecProperty Include="ProjectDirectory=$(MSBuildProjectDirectory)"/>
    </ItemGroup>
    <PropertyGroup Condition="'$(NuspecFile)' != '' and '$(NuspecProperties)' == ''">
      <NuspecProperties>@(NuspecProperty, ';')</NuspecProperties>
    </PropertyGroup>
  </Target>
 
  <!--
    Initialize Repository* properties from properties set by a source control package, if available in the project.
  -->
  <Target Name="_InitializeNuspecRepositoryInformationPropertiesWorkaround"
          DependsOnTargets="InitializeSourceControlInformation"
          Condition="'$(SourceControlInformationFeatureSupported)' == 'true'">
    <PropertyGroup>
      <!-- The project must specify PublishRepositoryUrl=true in order to publish the URL, in order to prevent inadvertent leak of internal URL. -->
      <RepositoryUrl Condition="'$(RepositoryUrl)' == '' and '$(PublishRepositoryUrl)' == 'true'">$(PrivateRepositoryUrl)</RepositoryUrl>
      <RepositoryCommit Condition="'$(RepositoryCommit)' == ''">$(SourceRevisionId)</RepositoryCommit>
    </PropertyGroup>
  </Target>
 
  <!--
    NuGet Restore uses PackageId and project name in the same namespace, so that project reference can be interchanged with a package reference.
    This causes issues however for leaf packages that are not to be referenced (such as analyzer or tools packages) when we want to name the package
    the same as an existing project in the solution. In that case we set PackageId to an invalid but unique value for Restore and override it for Pack
    with the desired name stored in $(NuspecPackageId).
  -->
  <PropertyGroup Condition="'$(NuspecPackageId)' != ''">
    <PackageId>*$(MSBuildProjectName)*</PackageId>
  </PropertyGroup>
 
  <!--
    Source packaging helpers.
  -->
 
  <PropertyGroup Condition="'$(IsPackable)' == 'true' and '$(IsSourcePackage)' == 'true'">
    <TargetsForTfmSpecificContentInPackage Condition="'$(NuspecFile)' == ''">$(TargetsForTfmSpecificContentInPackage);_AddSourceFilesToSourcePackage</TargetsForTfmSpecificContentInPackage>
  </PropertyGroup>
 
  <Target Name="_AddSourceFilesToSourcePackage">
    <PropertyGroup>
      <!-- TODO: language to dir name mapping (https://github.com/Microsoft/msbuild/issues/2101) -->
      <_LanguageDirName>$(DefaultLanguageSourceExtension.TrimStart('.'))</_LanguageDirName>
    </PropertyGroup>
 
    <ItemGroup>
      <_File Remove="@(_File)"/>
      <_File Include="$(MSBuildProjectDirectory)\**\*$(DefaultLanguageSourceExtension)" TargetDir="contentFiles/$(_LanguageDirName)/$(TargetFramework)" BuildAction="Compile" />
 
      <TfmSpecificPackageFile Include="@(_File)" PackagePath="%(_File.TargetDir)/%(_File.RecursiveDir)%(_File.FileName)%(_File.Extension)"/>
    </ItemGroup>
  </Target>
 
  <!-- BEGIN workaround for https://github.com/dotnet/sdk/issues/43339; remove after updated to VS 17.12 or a future 17.11 patch -->
  <Target Name="WorkaroundDotnetSdk43339" BeforeTargets="ResolvePackageAssets" Condition=" '$(MSBuildRuntimeType)' == 'Full' and $([MSBuild]::VersionLessThan($(MSBuildVersion), 17.12.0))">
    <PrimeSystemTextJson804 />
  </Target>
  <UsingTask
    TaskName="PrimeSystemTextJson804"
    TaskFactory="RoslynCodeTaskFactory"
    AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll" >
    <Task>
      <Code Type="Fragment" Language="cs">
<![CDATA[
try
{
    System.Reflection.Assembly.LoadFrom(@"$(MicrosoftNETBuildTasksDirectoryRoot)\..\..\..\DotnetTools\dotnet-format\BuildHost-net472\System.Text.Json.dll");
}
catch
{
    // Best effort: if something moves in the SDK don't break the build.
}
]]>
      </Code>
    </Task>
  </UsingTask>
  <!-- END workaround for https://github.com/dotnet/sdk/issues/43339 -->
 
</Project>