Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Convert AspNetCore transport pkgproj to Pack task
Converting the Microsoft.AspNetCore.Internal.Transport package to a proj
file which uses the NuGet Pack task.

Also moving some more packaging related targets into packaging.targets.
  • Loading branch information
ViktorHofer committed Jul 31, 2021
commit 156e0e106664746bd58b461ae46c6fa4fede44c0
65 changes: 65 additions & 0 deletions eng/packaging.targets
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,25 @@
<SuppressDependenciesWhenPacking Condition="'$(ExcludeFromPackage)' == 'true' or ('$(TargetsAnyOS)' != 'true' and $([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net5.0')))">true</SuppressDependenciesWhenPacking>
<PackageDesignerMarkerFile>$(MSBuildThisFileDirectory)useSharedDesignerContext.txt</PackageDesignerMarkerFile>
<PackageValidationBaselineVersion Condition="'$(PackageValidationBaselineVersion)' == ''">$([MSBuild]::Subtract($(MajorVersion), 1)).0.0</PackageValidationBaselineVersion>
<BeforePack>IncludeAnalyzersInPackage;$(BeforePack)</BeforePack>
<BuildAnalyzerReferences>$(BuildProjectReferences)</BuildAnalyzerReferences>
<BuildAnalyzerReferences Condition="'$(BuildingInsideVisualStudio)' == 'true'">false</BuildAnalyzerReferences>
</PropertyGroup>

<ItemGroup>
<!-- Ensure AnalyzerReference items are restored and built
The target framework of Analyzers has no relationship to that of the refrencing project,
so we don't apply TargetFramework filters nor do we pass in TargetFramework.
When BuildProjectReferences=false we make sure to set BuildReference=false to make
sure not to try to call GetTargetPath in the outerbuild of the analyzer project. -->
<ProjectReference Include="@(AnalyzerReference)"
SkipGetTargetFrameworkProperties="true"
UndefineProperties="TargetFramework"
ReferenceOutputAssembly="false"
PrivateAssets="all"
BuildReference="$(BuildAnalyzerReferences)" />
</ItemGroup>

<!-- There are some packages where we require only one ref for a specific framework to be present. In order to avoid problems with this package when targetting
dektop with RAR we will make sure there are no exclude=compile references in the package.
For more info, please check issues:
Expand Down Expand Up @@ -79,4 +96,52 @@
</TfmSpecificDebugSymbolsFile>
</ItemGroup>
</Target>

<Target Name="LibIntellisenseDocs"
Condition="'$(IncludeBuildOutput)' == 'true'">
<PropertyGroup>
<_intellisenseRootFolder>$(BuildOutputTargetFolder)</_intellisenseRootFolder>
<_intellisenseRootFolder Condition="'$(_intellisenseRootFolder)' == ''">lib</_intellisenseRootFolder>
</PropertyGroup>
<ItemGroup>
<TfmSpecificPackageFile Include="$(XmlDocFileRoot)1033\$(TargetName).xml"
Condition="Exists('$(XmlDocFileRoot)1033\$(TargetName).xml')"
PackagePath="$(_intellisenseRootFolder)/$(TargetFramework)" />
</ItemGroup>
</Target>

<Target Name="IncludeAnalyzersInPackage" Condition="'@(AnalyzerReference)' != ''">
<!-- Call a target in the analyzer project to get all the files it would normally place in a package.
These will be returned as items with identity pointing to the built file, and PackagePath metadata
set to their location in the package. IsSymbol metadata will be set to distinguish symbols. -->
<MSBuild Projects="@(AnalyzerReference)"
Targets="GetAnalyzerPackFiles">
<Output TaskParameter="TargetOutputs" ItemName="_AnalyzerFile" />
</MSBuild>

<ItemGroup>
<Content Include="@(_AnalyzerFile)" Pack="True" Condition="!%(_AnalyzerFile.IsSymbol)" />
<!-- Symbols don't honor PackagePath. By default they are placed in lib/%(TargetFramework).
Pack does honor TargetPath and does Path.Combine("lib/%(TargetFramework)", "%(TargetPath)"),
so a rooted path value for TargetPath will override lib.
https://github.com/NuGet/Home/issues/10860 -->
<_TargetPathsToSymbols Include="@(_AnalyzerFile)" TargetPath="/%(_AnalyzerFile.PackagePath)" Condition="%(_AnalyzerFile.IsSymbol)" />
</ItemGroup>
</Target>

<Target Name="GetAnalyzerPackFiles"
DependsOnTargets="$(GenerateNuspecDependsOn)"
Returns="@(_AnalyzerPackFile)">
<PropertyGroup>
<_analyzerPath>analyzers/dotnet</_analyzerPath>
<_analyzerPath Condition="'$(AnalyzerLanguage)' != ''">$(_analyzerPath)/$(AnalyzerLanguage)</_analyzerPath>
</PropertyGroup>
<ItemGroup>
<_AnalyzerPackFile Include="@(_BuildOutputInPackage)" IsSymbol="false" />
<_AnalyzerPackFile Include="@(_TargetPathsToSymbols)" IsSymbol="true" />
<_AnalyzerPackFile PackagePath="$(_analyzerPath)/%(TargetPath)" />
</ItemGroup>
<Error Condition="'%(_AnalyzerPackFile.TargetFramework)' != 'netstandard2.0'"
Text="Analyzers must only target netstandard2.0 since they run in the compiler which targets netstandard2.0. The following files were found to target '%(_AnalyzerPackFile.TargetFramework)': @(_AnalyzerPackFile)" />
</Target>
</Project>
60 changes: 0 additions & 60 deletions src/libraries/Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -272,65 +272,5 @@
</When>
</Choose>

<Target Name="LibIntellisenseDocs" Condition="'$(IncludeBuildOutput)' == 'true'">
<PropertyGroup>
<_intellisenseRootFolder>$(BuildOutputTargetFolder)</_intellisenseRootFolder>
<_intellisenseRootFolder Condition="'$(_intellisenseRootFolder)' == ''">lib</_intellisenseRootFolder>
</PropertyGroup>
<ItemGroup>
<TfmSpecificPackageFile Include="$(XmlDocFileRoot)1033\$(TargetName).xml"
Condition="Exists('$(XmlDocFileRoot)1033\$(TargetName).xml')"
PackagePath="$(_intellisenseRootFolder)/$(TargetFramework)" />
</ItemGroup>
</Target>

<PropertyGroup>
<BeforePack>IncludeAnalyzersInPackage;$(BeforePack)</BeforePack>
<BuildAnalyzerReferences>$(BuildProjectReferences)</BuildAnalyzerReferences>
<BuildAnalyzerReferences Condition="'$(BuildingInsideVisualStudio)' == 'true'">false</BuildAnalyzerReferences>
</PropertyGroup>

<ItemGroup>
<!-- Ensure AnalyzerReference items are restored and built
The target framework of Analyzers has no relationship to that of the refrencing project,
so we don't apply TargetFramework filters nor do we pass in TargetFramework.
When BuildProjectReferences=false we make sure to set BuildReference=false to make
sure not to try to call GetTargetPath in the outerbuild of the analyzer project. -->
<ProjectReference Include="@(AnalyzerReference)" SkipGetTargetFrameworkProperties="true" UndefineProperties="TargetFramework" ReferenceOutputAssembly="false" PrivateAssets="all" BuildReference="$(BuildAnalyzerReferences)" />
</ItemGroup>

<Target Name="IncludeAnalyzersInPackage" Condition="'@(AnalyzerReference)' != ''">
<!-- Call a target in the analyzer project to get all the files it would normally place in a package.
These will be returned as items with identity pointing to the built file, and PackagePath metadata
set to their location in the package. IsSymbol metadata will be set to distinguish symbols. -->
<MSBuild Projects="@(AnalyzerReference)"
Targets="GetAnalyzerPackFiles">
<Output TaskParameter="TargetOutputs" ItemName="_AnalyzerFile" />
</MSBuild>

<ItemGroup>
<Content Include="@(_AnalyzerFile)" Pack="True" Condition="!%(_AnalyzerFile.IsSymbol)" />
<!-- Symbols don't honor PackagePath. By default they are placed in lib/%(TargetFramework).
Pack does honor TargetPath and does Path.Combine("lib/%(TargetFramework)", "%(TargetPath)"),
so a rooted path value for TargetPath will override lib.
https://github.com/NuGet/Home/issues/10860 -->
<_TargetPathsToSymbols Include="@(_AnalyzerFile)" TargetPath="/%(_AnalyzerFile.PackagePath)" Condition="%(_AnalyzerFile.IsSymbol)" />
</ItemGroup>
</Target>

<Target Name="GetAnalyzerPackFiles" DependsOnTargets="$(GenerateNuspecDependsOn)" Returns="@(_AnalyzerPackFile)">
<PropertyGroup>
<_analyzerPath>analyzers/dotnet</_analyzerPath>
<_analyzerPath Condition="'$(AnalyzerLanguage)' != ''">$(_analyzerPath)/$(AnalyzerLanguage)</_analyzerPath>
</PropertyGroup>
<ItemGroup>
<_AnalyzerPackFile Include="@(_BuildOutputInPackage)" IsSymbol="false" />
<_AnalyzerPackFile Include="@(_TargetPathsToSymbols)" IsSymbol="true" />
<_AnalyzerPackFile PackagePath="$(_analyzerPath)/%(TargetPath)" />
</ItemGroup>
<Error Condition="'%(_AnalyzerPackFile.TargetFramework)' != 'netstandard2.0'"
Text="Analyzers must only target netstandard2.0 since they run in the compiler which targets netstandard2.0. The following files were found to target '%(_AnalyzerPackFile.TargetFramework)': @(_AnalyzerPackFile)" />
</Target>

<Import Project="$(MSBuildThisFileDirectory)workloads-testing.targets" />
</Project>

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,31 @@
<Project Sdk="Microsoft.Build.NoTargets">
<!-- These are wrapper project files for packaging.-->
<Project Sdk="Microsoft.Build.NoTargets">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFramework>$(NetCoreAppCurrent)</TargetFramework>
<IsPackable>true</IsPackable>
<IsShipping>false</IsShipping>
<!-- The project doesn't compile anything therefore create the package during build. -->
<GeneratePackageOnBuild Condition="'$(BuildingAnOfficialBuildLeg)' != 'true'">true</GeneratePackageOnBuild>
<!-- This is non-shipping package. -->
<DisablePackageBaselineValidation>true</DisablePackageBaselineValidation>
<PackageDescription>Internal transport package to provide aspnetcore with the assemblies that make up the Microsoft.ASPNetCore.App shared framework.</PackageDescription>
<!-- Reference elements are missing from the nuspec: https://github.com/NuGet/Home/issues/8684. -->
<NoWarn>$(NoWarn);NU5131</NoWarn>
</PropertyGroup>
</Project>

<ItemGroup>
<_analyzer Include="$(ASPNETCoreAppPackageRootPath)\analyzers\**\*.*" />
<_libDoc Include="$(ASPNETCoreAppPackageRuntimePath)\*.xml" />

<Content Include="@(_analyzer)"
Pack="true"
PackagePath="analyzers" />
<Content Include="$(ASPNETCoreAppPackageRefPath)\*.*;
@(_libDoc)"
Pack="true"
PackagePath="ref\$(NetCoreAppCurrent)" />
<Content Include="$(ASPNETCoreAppPackageRuntimePath)\*.*"
Exclude="@(_libDoc)"
Pack="true"
PackagePath="lib\$(NetCoreAppCurrent)" />
</ItemGroup>
</Project>