|
5 | 5 | <!-- Don't restore prebuilt packages during sourcebuild. --> |
6 | 6 | <DisablePackageBaselineValidation Condition="'$(DotNetBuildFromSource)' == 'true'">true</DisablePackageBaselineValidation> |
7 | 7 | <PackageValidationBaselineVersion Condition="'$(PackageValidationBaselineVersion)' == ''">$(NetCoreAppLatestStablePackageBaselineVersion)</PackageValidationBaselineVersion> |
8 | | - <!-- PackDependsOn is the right hook in a targets file if the NuGet.Build.Tasks.Pack nuget package is used, otherwise |
9 | | - BeforePack must be used. Setting both to ensure that we are always running before other targets. --> |
10 | | - <PackDependsOn>AddNETStandardCompatErrorFileForPackaging;IncludeAnalyzersInPackage;$(PackDependsOn)</PackDependsOn> |
11 | | - <BeforePack>AddNETStandardCompatErrorFileForPackaging;IncludeAnalyzersInPackage;$(BeforePack)</BeforePack> |
| 8 | + <BeforePack>$(BeforePack);IncludeAnalyzersInPackage;AddNETStandardCompatErrorFileForPackaging</BeforePack> |
12 | 9 | <TargetsForTfmSpecificContentInPackage>$(TargetsForTfmSpecificContentInPackage);AddRuntimeSpecificFilesToPackage;IncludeProjectReferencesWithPackAttributeInPackage</TargetsForTfmSpecificContentInPackage> |
13 | 10 | <IncludeBuildOutput Condition="'$(TargetPlatformIdentifier)' != ''">false</IncludeBuildOutput> |
14 | 11 | <!-- Don't include target platform specific dependencies, since we use the target platform to represent RIDs instead --> |
|
71 | 68 | <!-- Placeholders don't need a dependency group. --> |
72 | 69 | <NoWarn>$(NoWarn);NU5128</NoWarn> |
73 | 70 | </PropertyGroup> |
74 | | - <ItemGroup Condition="'$(AddNETFrameworkPlaceholderFileToPackage)' == 'true'"> |
75 | | - <None Include="$(PlaceholderFile)" PackagePath="$(BuildOutputTargetFolder)/$(NetFrameworkMinimum)" Pack="true" /> |
76 | | - </ItemGroup> |
77 | | - <ItemGroup Condition="'$(AddXamarinPlaceholderFilesToPackage)' == 'true'"> |
78 | | - <None Include="$(PlaceholderFile)" PackagePath="$(BuildOutputTargetFolder)/MonoAndroid10" Pack="true" /> |
79 | | - <None Include="$(PlaceholderFile)" PackagePath="$(BuildOutputTargetFolder)/MonoTouch10" Pack="true" /> |
80 | | - <None Include="$(PlaceholderFile)" PackagePath="$(BuildOutputTargetFolder)/xamarinios10" Pack="true" /> |
81 | | - <None Include="$(PlaceholderFile)" PackagePath="$(BuildOutputTargetFolder)/xamarinmac20" Pack="true" /> |
82 | | - <None Include="$(PlaceholderFile)" PackagePath="$(BuildOutputTargetFolder)/xamarintvos10" Pack="true" /> |
83 | | - <None Include="$(PlaceholderFile)" PackagePath="$(BuildOutputTargetFolder)/xamarinwatchos10" Pack="true" /> |
| 71 | + <ItemGroup> |
| 72 | + <None Include="$(PlaceholderFile)" |
| 73 | + Pack="true" |
| 74 | + PackagePath="$(BuildOutputTargetFolder)\$(NetFrameworkMinimum)\" |
| 75 | + Condition="'$(AddNETFrameworkPlaceholderFileToPackage)' == 'true'" /> |
| 76 | + <None Include="$(PlaceholderFile)" |
| 77 | + Pack="true" |
| 78 | + PackagePath="$(BuildOutputTargetFolder)\MonoAndroid10\; |
| 79 | + $(BuildOutputTargetFolder)\MonoTouch10\; |
| 80 | + $(BuildOutputTargetFolder)\xamarinios10\; |
| 81 | + $(BuildOutputTargetFolder)\xamarinmac20\; |
| 82 | + $(BuildOutputTargetFolder)\xamarintvos10\; |
| 83 | + $(BuildOutputTargetFolder)\xamarinwatchos10\" |
| 84 | + Condition="'$(AddXamarinPlaceholderFilesToPackage)' == 'true'" /> |
84 | 85 | </ItemGroup> |
85 | 86 | </When> |
86 | 87 | </Choose> |
87 | 88 |
|
| 89 | + <!-- Include a netstandard compat error if the project targets both .NETStandard and |
| 90 | + .NETCoreApp. This prohibits users to consume packages on an older .NETCoreApp version |
| 91 | + than the minimum supported one. --> |
| 92 | + <ItemGroup> |
| 93 | + <NETStandardCompatError Include="netcoreapp2.0" |
| 94 | + Supported="$(NetCoreAppMinimum)" |
| 95 | + Condition="$(TargetFrameworks.Contains('netstandard2.')) and |
| 96 | + ($(TargetFrameworks.Contains('$(NetCoreAppMinimum)')) or $(TargetFrameworks.Contains('$(NetCoreAppCurrent)')))" /> |
| 97 | + <NETStandardCompatError Include="net461" |
| 98 | + Supported="$(NetFrameworkMinimum)" |
| 99 | + Condition="$(TargetFrameworks.Contains('netstandard2.0')) and |
| 100 | + ($(TargetFrameworks.Contains('$(NetFrameworkMinimum)')) or $(TargetFrameworks.Contains('net47')) or $(TargetFrameworks.Contains('net48')))" /> |
| 101 | + </ItemGroup> |
| 102 | + |
88 | 103 | <!-- TODO: Remove this target when no library relies on the intellisense documentation file anymore.--> |
89 | 104 | <Target Name="ChangeDocumentationFileForPackaging" |
90 | 105 | AfterTargets="DocumentationProjectOutputGroup" |
|
114 | 129 | @(BuiltProjectOutputGroupOutput); |
115 | 130 | @(DocumentationProjectOutputGroupOutput)" /> |
116 | 131 | <TfmSpecificPackageFile Include="@(TfmRuntimeSpecificPackageFile)" |
117 | | - PackagePath="runtimes/$(_packageTargetRuntime)/$(BuildOutputTargetFolder)/$(_targetFrameworkWithoutSuffix)" /> |
| 132 | + PackagePath="runtimes\$(_packageTargetRuntime)\$(BuildOutputTargetFolder)\$(_targetFrameworkWithoutSuffix)\" /> |
118 | 133 | <TfmSpecificDebugSymbolsFile Include="$(RuntimeSymbolPath)" |
119 | 134 | TargetPath="/runtimes/$(_packageTargetRuntime)/$(BuildOutputTargetFolder)/$(_targetFrameworkWithoutSuffix)/%(Filename)%(Extension)" |
120 | 135 | TargetFramework="$(_targetFrameworkWithoutSuffix)" |
|
153 | 168 | Condition="'@(AnalyzerReference)' != '' and '$(IncludeMultiTargetRoslynComponentTargets)' == 'true'" |
154 | 169 | DependsOnTargets="GenerateMultiTargetRoslynComponentTargetsFile"> |
155 | 170 | <ItemGroup> |
156 | | - <Content Include="$(MultiTargetRoslynComponentTargetsFileIntermediatePath)" |
157 | | - PackagePath="build\$(PackageId).targets" |
158 | | - Pack="True" /> |
| 171 | + <Content Include="$(MultiTargetRoslynComponentTargetsFileIntermediatePath)" PackagePath="buildTransitive\netstandard2.0\$(PackageId).targets" /> |
| 172 | + <Content Include="$(MultiTargetRoslynComponentTargetsFileIntermediatePath)" PackagePath="buildTransitive\%(NETStandardCompatError.Supported)\$(PackageId).targets" Condition="'@(NETStandardCompatError)' != ''" /> |
159 | 173 | </ItemGroup> |
160 | 174 | </Target> |
161 | 175 |
|
|
175 | 189 | Overwrite="true" /> |
176 | 190 | </Target> |
177 | 191 |
|
178 | | - <!-- Include a netstandard compat error if the project targets both .NETStandard and |
179 | | - .NETCoreApp. This prohibits users to consume packages on an older .NETCoreApp version |
180 | | - than the minimum supported one. --> |
181 | | - <ItemGroup> |
182 | | - <NETStandardCompatError Include="netcoreapp2.0" |
183 | | - Supported="$(NetCoreAppMinimum)" |
184 | | - Condition="$(TargetFrameworks.Contains('netstandard2.')) and |
185 | | - ($(TargetFrameworks.Contains('$(NetCoreAppMinimum)')) or $(TargetFrameworks.Contains('$(NetCoreAppCurrent)'))) and |
186 | | - '$(DisableNETStandardCompatErrorForNETCoreApp)' != 'true'" /> |
187 | | - <NETStandardCompatError Include="net461" |
188 | | - Supported="$(NetFrameworkMinimum)" |
189 | | - Condition="$(TargetFrameworks.Contains('netstandard2.0')) and |
190 | | - ($(TargetFrameworks.Contains('$(NetFrameworkMinimum)')) or $(TargetFrameworks.Contains('net47')) or $(TargetFrameworks.Contains('net48'))) and |
191 | | - '$(DisableNETStandardCompatErrorForNETFramework)' != 'true'" /> |
192 | | - |
193 | | - </ItemGroup> |
194 | | - |
195 | 192 | <!-- Add targets file that marks a .NETStandard applicable tfm as unsupported. --> |
196 | 193 | <Target Name="AddNETStandardCompatErrorFileForPackaging" |
197 | | - Condition="'@(NETStandardCompatError)' != ''" |
| 194 | + Condition="'@(NETStandardCompatError)' != '' and '$(DisableNETStandardCompatErrors)' != 'true'" |
198 | 195 | Inputs="%(NETStandardCompatError.Identity)" |
199 | 196 | Outputs="unused"> |
200 | 197 | <PropertyGroup> |
201 | | - <_NETStandardCompatErrorFilePath>$(BaseIntermediateOutputPath)netstandardcompaterrors\%(NETStandardCompatError.Identity)\$(PackageId).targets</_NETStandardCompatErrorFilePath> |
| 198 | + <_NETStandardCompatErrorFilePath>$(BaseIntermediateOutputPath)netstandardcompaterror_%(NETStandardCompatError.Identity).targets</_NETStandardCompatErrorFilePath> |
202 | 199 | <_NETStandardCompatErrorFileTarget>NETStandardCompatError_$(PackageId.Replace('.', '_'))_$([System.String]::new('%(NETStandardCompatError.Supported)').Replace('.', '_'))</_NETStandardCompatErrorFileTarget> |
203 | 200 | <_NETStandardCompatErrorFileContent> |
204 | 201 | <![CDATA[<Project InitialTargets="$(_NETStandardCompatErrorFileTarget)"> |
|
208 | 205 | </Target> |
209 | 206 | </Project>]]> |
210 | 207 | </_NETStandardCompatErrorFileContent> |
| 208 | + <_NETStandardCompatErrorPlaceholderFilePackagePath>buildTransitive$([System.IO.Path]::DirectorySeparatorChar)%(NETStandardCompatError.Supported)</_NETStandardCompatErrorPlaceholderFilePackagePath> |
211 | 209 | </PropertyGroup> |
212 | 210 |
|
213 | 211 | <WriteLinesToFile File="$(_NETStandardCompatErrorFilePath)" |
|
216 | 214 | WriteOnlyWhenDifferent="true" /> |
217 | 215 |
|
218 | 216 | <ItemGroup> |
| 217 | + <_PackageBuildFile Include="@(None->Metadata('PackagePath')); |
| 218 | + @(Content->Metadata('PackagePath'))" /> |
| 219 | + <_PackageBuildFile PackagePathWithoutFilename="$([System.IO.Path]::GetDirectoryName('%(Identity)'))" /> |
| 220 | + |
219 | 221 | <None Include="$(_NETStandardCompatErrorFilePath)" |
220 | | - PackagePath="buildTransitive\%(NETStandardCompatError.Identity)" |
| 222 | + PackagePath="buildTransitive\%(NETStandardCompatError.Identity)\$(PackageId).targets" |
221 | 223 | Pack="true" /> |
| 224 | + <!-- Add the placeholder file to the supported target framework buildTransitive folder, if it's empty. --> |
222 | 225 | <None Include="$(PlaceholderFile)" |
223 | | - PackagePath="buildTransitive\%(NETStandardCompatError.Supported)" |
224 | | - Pack="true" /> |
225 | | - <FileWrites Include="$(_NETStandardCompatErrorFilePath)" /> |
| 226 | + PackagePath="$(_NETStandardCompatErrorPlaceholderFilePackagePath)\$(PackageId).targets" |
| 227 | + Pack="true" |
| 228 | + Condition="'@(_PackageBuildFile)' == '' or |
| 229 | + !@(_PackageBuildFile->AnyHaveMetadataValue('PackagePathWithoutFilename', '$(_NETStandardCompatErrorPlaceholderFilePackagePath)'))" /> |
226 | 230 | </ItemGroup> |
227 | 231 | </Target> |
228 | 232 |
|
229 | 233 | <Target Name="IncludeProjectReferencesWithPackAttributeInPackage" |
230 | | - Condition="'@(ProjectReference->WithMetadataValue('Pack', 'true'))' != ''" |
| 234 | + Condition="'@(ProjectReference)' != '' and @(ProjectReference->AnyHaveMetadataValue('Pack', 'true'))" |
231 | 235 | DependsOnTargets="BuildOnlySettings;ResolveReferences"> |
232 | 236 | <ItemGroup> |
233 | 237 | <!-- Add ReferenceCopyLocalPaths for ProjectReferences which are flagged as Pack="true" into the package. --> |
234 | 238 | <_projectReferenceCopyLocalPaths Include="@(ReferenceCopyLocalPaths->WithMetadataValue('ReferenceSourceTarget', 'ProjectReference')->WithMetadataValue('Pack', 'true'))" /> |
235 | 239 | <TfmSpecificPackageFile Include="@(_projectReferenceCopyLocalPaths)" |
236 | | - PackagePath="$([MSBuild]::ValueOrDefault('%(ReferenceCopyLocalPaths.PackagePath)', '$(BuildOutputTargetFolder)/$(TargetFramework)'))" /> |
| 240 | + PackagePath="$([MSBuild]::ValueOrDefault('%(ReferenceCopyLocalPaths.PackagePath)', '$(BuildOutputTargetFolder)\$(TargetFramework)\'))" /> |
237 | 241 | <TfmSpecificDebugSymbolsFile Include="@(TfmSpecificPackageFile->WithMetadataValue('Extension', '.pdb'))" |
238 | 242 | TargetPath="/%(TfmSpecificPackageFile.PackagePath)/%(Filename)%(Extension)" |
239 | 243 | TargetFramework="$(TargetFramework)" |
|
249 | 253 | <_referenceAssemblyPaths Include="@(_projectReferenceCopyLocalPaths->WithMetadataValue('Extension', '.dll')->WithMetadataValue('IncludeReferenceAssemblyInPackage', 'true')->Metadata('ReferenceAssembly'))" /> |
250 | 254 | <_referenceAssemblyPaths Include="@(_projectReferenceCopyLocalPaths->WithMetadataValue('Extension', '.xml')->WithMetadataValue('IncludeReferenceAssemblyInPackage', 'true'))" /> |
251 | 255 | <TfmSpecificPackageFile Include="@(_referenceAssemblyPaths)" |
252 | | - PackagePath="ref/$(TargetFramework)" /> |
| 256 | + PackagePath="ref\$(TargetFramework)\" /> |
253 | 257 | </ItemGroup> |
254 | 258 | </Target> |
255 | 259 |
|
|
0 commit comments