summaryrefslogtreecommitdiff
path: root/.packages/microsoft.dotnet.arcade.sdk/1.0.0-beta.20113.5/tools/Workarounds.targets
blob: 04749819bab561771f3a3197909b7f689b7108af (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
<?xml version="1.0" encoding="utf-8"?>
<!-- Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the MIT license. See the LICENSE file in the project root for more information. -->
<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>

  <!--
    Workaround to fix IntelliSense file generation for XAML projects
    https://github.com/dotnet/project-system/issues/2488
  -->
  <Target Name="WorkaroundForXamlIntelliSenseBuildIssue" AfterTargets="_CheckCompileDesignTimePrerequisite">
    <PropertyGroup>
      <BuildingProject>false</BuildingProject>
    </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>

  <ItemGroup Condition="'$(IsWpfTempProject)' == 'true' and '$(TargetFrameworkIdentifier)' == '.NETFramework'">
    <Reference Include="mscorlib" Pack="false" />
  </ItemGroup>

  <!--
    Workaround for a race condition https://github.com/Microsoft/msbuild/issues/1479.
  -->
  <PropertyGroup>
    <TargetFrameworkMonikerAssemblyAttributesPath>$(IntermediateOutputPath)$(TargetFrameworkMoniker).AssemblyAttributes$(DefaultLanguageSourceExtension)</TargetFrameworkMonikerAssemblyAttributesPath>
    <TargetFrameworkMonikerAssemblyAttributesFileClean>true</TargetFrameworkMonikerAssemblyAttributesFileClean>
  </PropertyGroup>

  <!-- 
     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>

      <_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)
      </_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>
</Project>