Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
</ItemGroup>

<Import Project="Sdk.targets" Sdk="Microsoft.DotNet.Arcade.Sdk" />
<Import Project="$(RepositoryEngineeringDir)packaging.targets" Condition="'$(IsPackable)' == 'true'" />

<!-- Put it after Sdk.targets imports to override values from StrongName.targets. It's needed to avoid NGEN validation issues on VS exp insertions. -->
<PropertyGroup Condition="'$(SignType)' == 'test'">
Expand Down
Empty file added eng/_._
Empty file.
60 changes: 60 additions & 0 deletions eng/packaging.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<Project>

<PropertyGroup>
<BeforePack>$(BeforePack);AddNETStandardCompatErrorFileForPackaging</BeforePack>
<PlaceholderFile>$(RepositoryEngineeringDir)_._</PlaceholderFile>
</PropertyGroup>

<!-- Include a netstandard compat error if the project targets .NETStandard and runtimes.
This prohibits users to consume packages on an older .NETCoreApp version than the minimum supported one. -->
<ItemGroup>
<NETStandardCompatError Include="netcoreapp2.0"
Supported="$(LatestDotNetCoreForMSBuild)"
Condition="$(TargetFrameworks.Contains('netstandard2.')) and $(TargetFrameworks.Contains('$(LatestDotNetCoreForMSBuild)'))" />
<NETStandardCompatError Include="net461"
Supported="$(FullFrameworkTFM)"
Condition="$(TargetFrameworks.Contains('netstandard2.0')) and $(TargetFrameworks.Contains('$(FullFrameworkTFM)')) and !$(TargetFrameworks.Contains('net35'))" />
</ItemGroup>

<!-- Add targets file that marks a .NETStandard applicable tfm as unsupported. -->
<Target Name="AddNETStandardCompatErrorFileForPackaging"
Condition="'@(NETStandardCompatError)' != '' and '$(DisableNETStandardCompatErrors)' != 'true'"
Inputs="%(NETStandardCompatError.Identity)"
Outputs="unused">
<PropertyGroup>
<_NETStandardCompatErrorFilePath>$(BaseIntermediateOutputPath)netstandardcompaterror_%(NETStandardCompatError.Identity).targets</_NETStandardCompatErrorFilePath>
<_NETStandardCompatErrorFileTarget>NETStandardCompatError_$(PackageId.Replace('.', '_'))_$([System.String]::new('%(NETStandardCompatError.Supported)').Replace('.', '_'))</_NETStandardCompatErrorFileTarget>
<_NETStandardCompatErrorFileContent>
<![CDATA[<Project InitialTargets="$(_NETStandardCompatErrorFileTarget)">
<Target Name="$(_NETStandardCompatErrorFileTarget)"
Condition="'%24(SuppressTfmSupportBuildWarnings)' == ''">
<Warning Text="$(PackageId) $(PackageVersion) doesn't support %24(TargetFramework) and has not been tested with it. Consider upgrading your TargetFramework to %(NETStandardCompatError.Supported) or later. You may also set &lt%3BSuppressTfmSupportBuildWarnings&gt%3Btrue&lt%3B/SuppressTfmSupportBuildWarnings&gt%3B in the project file to ignore this warning and attempt to run in this unsupported configuration at your own risk." />
</Target>
Comment thread
ViktorHofer marked this conversation as resolved.
</Project>]]>
</_NETStandardCompatErrorFileContent>
<_NETStandardCompatErrorPlaceholderFilePackagePath>buildTransitive$([System.IO.Path]::DirectorySeparatorChar)%(NETStandardCompatError.Supported)</_NETStandardCompatErrorPlaceholderFilePackagePath>
</PropertyGroup>

<WriteLinesToFile File="$(_NETStandardCompatErrorFilePath)"
Lines="$(_NETStandardCompatErrorFileContent)"
Overwrite="true"
WriteOnlyWhenDifferent="true" />

<ItemGroup>
<_PackageBuildFile Include="@(None->Metadata('PackagePath'));
@(Content->Metadata('PackagePath'))" />
<_PackageBuildFile PackagePathWithoutFilename="$([System.IO.Path]::GetDirectoryName('%(Identity)'))" />

<None Include="$(_NETStandardCompatErrorFilePath)"
PackagePath="buildTransitive\%(NETStandardCompatError.Identity)\$(PackageId).targets"
Pack="true" />
<!-- Add the placeholder file to the supported target framework buildTransitive folder, if it's empty. -->
<None Include="$(PlaceholderFile)"
PackagePath="$(_NETStandardCompatErrorPlaceholderFilePackagePath)\"
Pack="true"
Condition="'@(_PackageBuildFile)' == '' or
!@(_PackageBuildFile->AnyHaveMetadataValue('PackagePathWithoutFilename', '$(_NETStandardCompatErrorPlaceholderFilePackagePath)'))" />
</ItemGroup>
</Target>

</Project>
3 changes: 2 additions & 1 deletion src/MSBuild/MSBuild.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
<IncludeSatelliteOutputInPack>false</IncludeSatelliteOutputInPack>
<NoPackageAnalysis>true</NoPackageAnalysis>
<AddAppConfigToBuildOutputs>false</AddAppConfigToBuildOutputs>
<DisableNETStandardCompatErrors>true</DisableNETStandardCompatErrors>

<!-- Setting DebugType here goes hand in hand with eng\AfterSigning.targets. This is to prompt the x64 build to produce a 'full' .pdb that's `more compatible` then 'portable' and 'embedded' .pdbs. This doesn't get set on 32 bit architecture, which will default to 'embedded' and 'pdb2pdb' will convert those as needed. See https://github.com/dotnet/msbuild/pull/5070 for context. -->
<DebugType Condition="'$(Platform)' == 'x64'">full</DebugType>
Expand Down Expand Up @@ -319,4 +320,4 @@
</Target>

</Project>


Loading