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
3 changes: 0 additions & 3 deletions docs/coding-guidelines/libraries-packaging.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,3 @@ In order to mitigate design-time/build-time performance issues with source gener
<DisableSourceGeneratorPropertyName>CustomPropertyName</DisableSourceGeneratorPropertyName>
</PropertyGroup>
```
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add something to the docs around where the -runtime suffix is supported? Does the infra fail in a sensible way when it's misused (if not, should we explicitly error)?

Copy link
Member Author

@ViktorHofer ViktorHofer Feb 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After dotnet/arcade#8418 merged and consumed, NuGet will throw during restore if a non .NETCoreApp tfm has a suffix in its alias. It makes sense to add section to the project guidelines clarifying which tfms can be runtime specific and how to apply conditions to specific runtimes correctly.

I plan to update that document with #64500.


### .NETFramework RID specific assets
When targeting .NETFramework, RID specific assets are automatically added to the package if the project contains other compatible RID specific assets, mainly `netstandard2.0-windows`.
15 changes: 0 additions & 15 deletions eng/BeforeTargetFrameworkInference.targets
Original file line number Diff line number Diff line change
@@ -1,20 +1,5 @@
<Project>

<PropertyGroup Condition="$(TargetFramework.Contains('-'))">
<_OriginalTargetFramework>$(TargetFramework)</_OriginalTargetFramework>
<TargetFrameworkSuffix>$(TargetFramework.SubString($([MSBuild]::Add($(TargetFramework.IndexOf('-')), 1))))</TargetFrameworkSuffix>
<!-- Strip away the TargetPlatform during the build for non .NETCoreApp frameworks because the assets file does not know about the TargetPlatform. -->
<TargetFramework>$([System.Text.RegularExpressions.Regex]::Replace('$(TargetFramework)', '$(TargetFrameworkPattern)', '${1}'))</TargetFramework>
</PropertyGroup>

<Import Project="$(MSBuildThisDirectory)targetframeworksuffix.props" Condition="'$(DesignTimeBuild)' == 'true'" />

<PropertyGroup>
<IntermediateOutputPath>$([MSBuild]::NormalizeDirectory('$(BaseIntermediateOutputPath)', '$(TargetFramework)-$(Configuration)'))</IntermediateOutputPath>
<IntermediateOutputPath Condition="'$(TargetFrameworkSuffix)' != '' and !$(TargetFramework.Contains('-'))">$([MSBuild]::NormalizeDirectory('$(BaseIntermediateOutputPath)', '$(TargetFramework)-$(TargetFrameworkSuffix)-$(Configuration)'))</IntermediateOutputPath>
<!-- setting the output paths -->
<OutputPath>$([MSBuild]::NormalizeDirectory('$(BaseOutputPath)', '$(TargetFramework)-$(Configuration)'))</OutputPath>
<OutputPath Condition="'$(TargetFrameworkSuffix)' != '' and !$(TargetFramework.Contains('-'))">$([MSBuild]::NormalizeDirectory('$(BaseOutputPath)', '$(TargetFramework)-$(TargetFrameworkSuffix)-$(Configuration)'))</OutputPath>
</PropertyGroup>

</Project>
5 changes: 1 addition & 4 deletions eng/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -216,10 +216,7 @@ if ($vs) {
# Respect the RuntimeConfiguration variable for building inside VS with different runtime configurations
$env:RUNTIMECONFIGURATION=$runtimeConfiguration
}

# Restore the solution to workaround https://github.com/dotnet/runtime/issues/32205
Invoke-Expression "& dotnet restore $vs"


# Launch Visual Studio with the locally defined environment variables
."$vs"

Expand Down
20 changes: 9 additions & 11 deletions eng/packaging.targets
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<PackDependsOn>AddNETStandardCompatErrorFileForPackaging;IncludeAnalyzersInPackage;$(PackDependsOn)</PackDependsOn>
<BeforePack>AddNETStandardCompatErrorFileForPackaging;IncludeAnalyzersInPackage;$(BeforePack)</BeforePack>
<TargetsForTfmSpecificContentInPackage>$(TargetsForTfmSpecificContentInPackage);AddRuntimeSpecificFilesToPackage;IncludePrivateProjectReferencesWithPackAttributeInPackage</TargetsForTfmSpecificContentInPackage>
<IncludeBuildOutput Condition="'$(TargetFrameworkSuffix)' != ''">false</IncludeBuildOutput>
<IncludeBuildOutput Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp' and '$(TargetPlatformIdentifier)' != ''">false</IncludeBuildOutput>
<!-- Don't include target platform specific dependencies, since we use the target platform to represent RIDs instead -->
<SuppressDependenciesWhenPacking Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp' and '$(TargetPlatformIdentifier)' != ''">true</SuppressDependenciesWhenPacking>
<PackageDesignerMarkerFile>$(MSBuildThisFileDirectory)useSharedDesignerContext.txt</PackageDesignerMarkerFile>
Expand Down Expand Up @@ -73,7 +73,6 @@
</PropertyGroup>
<ItemGroup Condition="'$(AddNETFrameworkPlaceholderFileToPackage)' == 'true'">
<None Include="$(PlaceholderFile)" PackagePath="$(BuildOutputTargetFolder)/$(NetFrameworkMinimum)" Pack="true" />
<None Include="$(PlaceholderFile)" PackagePath="runtimes/win/$(BuildOutputTargetFolder)/$(NetFrameworkMinimum)" Pack="true" Condition="$(TargetFrameworks.Contains('netstandard2.0-windows'))" />
</ItemGroup>
<ItemGroup Condition="'$(AddXamarinPlaceholderFilesToPackage)' == 'true'">
<None Include="$(PlaceholderFile)" PackagePath="$(BuildOutputTargetFolder)/MonoAndroid10" Pack="true" />
Expand All @@ -96,30 +95,29 @@
</ItemGroup>
</Target>

<!-- Add runtime specific file into the package if the tfm is RID specific or if the tfm targets .NETFramework and netstandard2.0-windows TFM is present.
This is necessary as compatible RID specific tfms win over compatible RID agnostic tfms. Hence without this, netstandard2.0-windows would win over net461. -->
<!-- Add runtime specific file into the package if the tfm is RID specific. -->
<Target Name="AddRuntimeSpecificFilesToPackage"
DependsOnTargets="BuiltProjectOutputGroup;
DocumentationProjectOutputGroup;
SatelliteDllsProjectOutputGroup;
$(TargetsForTfmSpecificBuildOutput)"
Condition="'$(TargetFrameworkSuffix)' != '' or
('$(TargetFrameworkIdentifier)' == '.NETFramework' and $(TargetFrameworks.Contains('netstandard2.0-windows')))">
Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp' and '$(TargetPlatformIdentifier)' != ''">
<PropertyGroup>
<RuntimeSymbolPath>$(TargetDir)$(TargetName).pdb</RuntimeSymbolPath>
<_packageTargetRuntime Condition="'$(TargetFrameworkIdentifier)' != '.NETFramework'">$(PackageTargetRuntime)</_packageTargetRuntime>
<_packageTargetRuntime Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework'">win</_packageTargetRuntime>
<_packageTargetRuntime>$(TargetPlatformIdentifier.ToLowerInvariant().Replace('windows', 'win'))</_packageTargetRuntime>
<_targetFrameworkWithoutSuffix>$(TargetFramework)</_targetFrameworkWithoutSuffix>
<_targetFrameworkWithoutSuffix Condition="$(TargetFramework.Contains('-'))">$(TargetFramework.SubString(0, $(TargetFramework.IndexOf('-'))))</_targetFrameworkWithoutSuffix>
</PropertyGroup>

<ItemGroup>
<TfmRuntimeSpecificPackageFile Include="@(SatelliteDllsProjectOutputGroupOutput);
@(BuiltProjectOutputGroupOutput);
@(DocumentationProjectOutputGroupOutput)" />
<TfmSpecificPackageFile Include="@(TfmRuntimeSpecificPackageFile)"
PackagePath="runtimes/$(_packageTargetRuntime)/$(BuildOutputTargetFolder)/$(TargetFrameworkWithoutSuffix)" />
PackagePath="runtimes/$(_packageTargetRuntime)/$(BuildOutputTargetFolder)/$(_targetFrameworkWithoutSuffix)" />
<TfmSpecificDebugSymbolsFile Include="$(RuntimeSymbolPath)"
TargetPath="/runtimes/$(_packageTargetRuntime)/$(BuildOutputTargetFolder)/$(TargetFrameworkWithoutSuffix)/%(Filename)%(Extension)"
TargetFramework="$(TargetFrameworkWithoutSuffix)"
TargetPath="/runtimes/$(_packageTargetRuntime)/$(BuildOutputTargetFolder)/$(_targetFrameworkWithoutSuffix)/%(Filename)%(Extension)"
TargetFramework="$(_targetFrameworkWithoutSuffix)"
Condition="'$(IncludeSymbols)' == 'true' and Exists('$(RuntimeSymbolPath)')" />
</ItemGroup>
</Target>
Expand Down
12 changes: 0 additions & 12 deletions eng/slngen.nuget.config

This file was deleted.

46 changes: 16 additions & 30 deletions eng/targetframeworksuffix.props
Original file line number Diff line number Diff line change
Expand Up @@ -8,105 +8,91 @@
This is required for platforms not expected to have a version,
and we currently omit the version for all platforms. -->
<SupportedOSPlatformVersion>0.0</SupportedOSPlatformVersion>
<TargetPlatformIdentifier Condition="$(TargetFramework.Contains('-'))">$(TargetFramework.SubString($([MSBuild]::Add($(TargetFramework.IndexOf('-')), 1))))</TargetPlatformIdentifier>
</PropertyGroup>

<PropertyGroup Condition="'$(TargetFrameworkSuffix)' != '' and '$(TargetFrameworkSuffix)' != 'windows'">
<TargetPlatformIdentifier>$(TargetFrameworkSuffix)</TargetPlatformIdentifier>
<PropertyGroup Condition="'$(TargetPlatformIdentifier)' != '' and '$(TargetPlatformIdentifier)' != 'windows'">
<TargetPlatformVersion>1.0</TargetPlatformVersion>
<TargetPlatformMoniker>$(TargetFrameworkSuffix),Version=$(TargetPlatformVersion)</TargetPlatformMoniker>
</PropertyGroup>

<Choose>
<When Condition="'$(TargetFrameworkSuffix)' == 'windows'">
<When Condition="'$(TargetPlatformIdentifier)' == 'windows'">
<PropertyGroup>
<TargetsWindows>true</TargetsWindows>
<PackageTargetRuntime>win</PackageTargetRuntime>
</PropertyGroup>
</When>
<When Condition="'$(TargetFrameworkSuffix)' == 'Unix'">
<When Condition="'$(TargetPlatformIdentifier)' == 'Unix'">
<PropertyGroup>
<TargetsUnix>true</TargetsUnix>
<PackageTargetRuntime>unix</PackageTargetRuntime>
</PropertyGroup>
</When>
<When Condition="'$(TargetFrameworkSuffix)' == 'Linux'">
<When Condition="'$(TargetPlatformIdentifier)' == 'Linux'">
<PropertyGroup>
<TargetsUnix>true</TargetsUnix>
<TargetsLinux>true</TargetsLinux>
<PackageTargetRuntime>linux</PackageTargetRuntime>
</PropertyGroup>
</When>
<When Condition="'$(TargetFrameworkSuffix)' == 'Android'">
<When Condition="'$(TargetPlatformIdentifier)' == 'Android'">
<PropertyGroup>
<TargetsUnix>true</TargetsUnix>
<TargetsLinux>true</TargetsLinux>
<TargetsAndroid>true</TargetsAndroid>
<PackageTargetRuntime>android</PackageTargetRuntime>
</PropertyGroup>
</When>
<When Condition="'$(TargetFrameworkSuffix)' == 'OSX'">
<When Condition="'$(TargetPlatformIdentifier)' == 'OSX'">
<PropertyGroup>
<TargetsUnix>true</TargetsUnix>
<TargetsOSX>true</TargetsOSX>
<PackageTargetRuntime>osx</PackageTargetRuntime>
</PropertyGroup>
</When>
<When Condition="'$(TargetFrameworkSuffix)' == 'MacCatalyst'">
<When Condition="'$(TargetPlatformIdentifier)' == 'MacCatalyst'">
<PropertyGroup>
<TargetsUnix>true</TargetsUnix>
<TargetsMacCatalyst>true</TargetsMacCatalyst>
<PackageTargetRuntime>maccatalyst</PackageTargetRuntime>
</PropertyGroup>
</When>
<When Condition="'$(TargetFrameworkSuffix)' == 'tvOS'">
<When Condition="'$(TargetPlatformIdentifier)' == 'tvOS'">
<PropertyGroup>
<TargetsUnix>true</TargetsUnix>
<TargetstvOS>true</TargetstvOS>
<PackageTargetRuntime>tvos</PackageTargetRuntime>
</PropertyGroup>
</When>
<When Condition="'$(TargetFrameworkSuffix)' == 'iOS'">
<When Condition="'$(TargetPlatformIdentifier)' == 'iOS'">
<PropertyGroup>
<TargetsUnix>true</TargetsUnix>
<TargetsiOS>true</TargetsiOS>
<PackageTargetRuntime>ios</PackageTargetRuntime>
</PropertyGroup>
</When>
<When Condition="'$(TargetFrameworkSuffix)' == 'FreeBSD'">
<When Condition="'$(TargetPlatformIdentifier)' == 'FreeBSD'">
<PropertyGroup>
<TargetsUnix>true</TargetsUnix>
<TargetsFreeBSD>true</TargetsFreeBSD>
<PackageTargetRuntime>freebsd</PackageTargetRuntime>
</PropertyGroup>
</When>
<When Condition="'$(TargetFrameworkSuffix)' == 'NetBSD'">
<When Condition="'$(TargetPlatformIdentifier)' == 'NetBSD'">
<PropertyGroup>
<TargetsUnix>true</TargetsUnix>
<TargetsNetBSD>true</TargetsNetBSD>
<PackageTargetRuntime>netbsd</PackageTargetRuntime>
</PropertyGroup>
</When>
<When Condition="'$(TargetFrameworkSuffix)' == 'illumos'">
<When Condition="'$(TargetPlatformIdentifier)' == 'illumos'">
<PropertyGroup>
<TargetsUnix>true</TargetsUnix>
<Targetsillumos>true</Targetsillumos>
<PackageTargetRuntime>illumos</PackageTargetRuntime>
</PropertyGroup>
</When>
<When Condition="'$(TargetFrameworkSuffix)' == 'Solaris'">
<When Condition="'$(TargetPlatformIdentifier)' == 'Solaris'">
<PropertyGroup>
<TargetsUnix>true</TargetsUnix>
<TargetsSolaris>true</TargetsSolaris>
<PackageTargetRuntime>solaris</PackageTargetRuntime>
</PropertyGroup>
</When>
<When Condition="'$(TargetFrameworkSuffix)' == 'Browser'">
<When Condition="'$(TargetPlatformIdentifier)' == 'Browser'">
<PropertyGroup>
<TargetsBrowser>true</TargetsBrowser>
<PackageTargetRuntime>browser</PackageTargetRuntime>
</PropertyGroup>
</When>
<When Condition="'$(TargetFrameworkSuffix)' == ''">
<When Condition="'$(TargetPlatformIdentifier)' == ''">
<PropertyGroup>
<TargetsAnyOS>true</TargetsAnyOS>
</PropertyGroup>
Expand Down
7 changes: 3 additions & 4 deletions eng/testing/tests.props
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,9 @@

<PropertyGroup Condition="'$(TargetsMobile)' == 'true'">
<!-- Test runners are built as part of libs.pretest so we need to use libraries configuration -->
<MobileRunnersDirSuffix>$(NetCoreAppCurrent)-$(Configuration)</MobileRunnersDirSuffix>
<AppleTestRunnerDir>$([MSBuild]::NormalizeDirectory('$(ArtifactsBinDir)', 'AppleTestRunner', '$(MobileRunnersDirSuffix)'))</AppleTestRunnerDir>
<AndroidTestRunnerDir>$([MSBuild]::NormalizeDirectory('$(ArtifactsBinDir)', 'AndroidTestRunner', '$(MobileRunnersDirSuffix)'))</AndroidTestRunnerDir>
<WasmTestRunnerDir>$([MSBuild]::NormalizeDirectory('$(ArtifactsBinDir)', 'WasmTestRunner', '$(MobileRunnersDirSuffix)'))</WasmTestRunnerDir>
<AppleTestRunnerDir>$([MSBuild]::NormalizeDirectory('$(ArtifactsBinDir)', 'AppleTestRunner', '$(Configuration)', '$(NetCoreAppCurrent)'))</AppleTestRunnerDir>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is this related to the rest of the change?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same reason as above. The IntermediateOutputPath and the OutputPath of the test runners changed with the removal of the AppendTargetFrameworkToOutputPath=false setting and I'm updating hardcoded paths here.

<AndroidTestRunnerDir>$([MSBuild]::NormalizeDirectory('$(ArtifactsBinDir)', 'AndroidTestRunner', '$(Configuration)', '$(NetCoreAppCurrent)'))</AndroidTestRunnerDir>
<WasmTestRunnerDir>$([MSBuild]::NormalizeDirectory('$(ArtifactsBinDir)', 'WasmTestRunner', '$(Configuration)', '$(NetCoreAppCurrent)'))</WasmTestRunnerDir>

<RuntimeIdentifier>$(PackageRID)</RuntimeIdentifier>
<SelfContained>true</SelfContained>
Expand Down
5 changes: 0 additions & 5 deletions src/libraries/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,6 @@
<!-- We can't generate an apphost without restoring the targeting pack. -->
<UseAppHost>false</UseAppHost>
<EnableDefaultItems>false</EnableDefaultItems>
<!--
Microsoft.NET.TargetFrameworkInference.targets appends the TargetFramework.
We do this manually and use the Configuration instead.
-->
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
</PropertyGroup>

<!-- Language configuration -->
Expand Down
12 changes: 0 additions & 12 deletions src/libraries/Microsoft.Extensions.Configuration.Xml/NuGet.config

This file was deleted.

12 changes: 0 additions & 12 deletions src/libraries/Microsoft.Extensions.Configuration/NuGet.config

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

<_generateRuntimeGraphTargetFramework Condition="'$(MSBuildRuntimeType)' == 'core'">$(NetCoreAppToolCurrent)</_generateRuntimeGraphTargetFramework>
<_generateRuntimeGraphTargetFramework Condition="'$(MSBuildRuntimeType)' != 'core'">net472</_generateRuntimeGraphTargetFramework>
<_generateRuntimeGraphTask>$([MSBuild]::NormalizePath('$(BaseOutputPath)', '$(_generateRuntimeGraphTargetFramework)-$(Configuration)', '$(AssemblyName).dll'))</_generateRuntimeGraphTask>
<_generateRuntimeGraphTask>$([MSBuild]::NormalizePath('$(BaseOutputPath)', $(Configuration), '$(_generateRuntimeGraphTargetFramework)', '$(AssemblyName).dll'))</_generateRuntimeGraphTask>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is this related to the rest of the change?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I change the IntermediateOutputPath and the OutputPath by removing the AppendTargetFrameworkToOutputPath=false setting in the libraries Directory.Build.props file, hence a few hardcoded paths need to be updated.

<!-- When building from source, ensure the RID we're building for is part of the RID graph -->
<AdditionalRuntimeIdentifiers Condition="'$(DotNetBuildFromSource)' == 'true'">$(AdditionalRuntimeIdentifiers);$(OutputRID)</AdditionalRuntimeIdentifiers>
</PropertyGroup>
Expand Down
12 changes: 0 additions & 12 deletions src/libraries/Microsoft.VisualBasic.Core/NuGet.config

This file was deleted.

12 changes: 0 additions & 12 deletions src/libraries/Microsoft.Win32.Registry.AccessControl/NuGet.config

This file was deleted.

Loading