Skip to content

Commit

Permalink
Clean-up in src/Layout/redist (#46994)
Browse files Browse the repository at this point in the history
  • Loading branch information
ViktorHofer authored Feb 24, 2025
1 parent c3dcbd6 commit 2ae52ef
Show file tree
Hide file tree
Showing 21 changed files with 96 additions and 204 deletions.
2 changes: 2 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@

<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
<CentralPackageTransitivePinningEnabled>true</CentralPackageTransitivePinningEnabled>

<SdkLayoutOutputDirectory>$(ArtifactsBinDir)redist\$(Configuration)\layouts\dotnet-toolset-internal\</SdkLayoutOutputDirectory>
</PropertyGroup>

<PropertyGroup Condition="'$(IsTestProject)' == 'true'">
Expand Down
3 changes: 0 additions & 3 deletions src/Installer/redist-installer/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@
<ProductMonikerRid Condition="'$(ProductMonikerRid)' == ''">$(Rid)</ProductMonikerRid>

<PortableProductMonikerRid Condition="'$(PortableProductMonikerRid)' == ''">$(PortableRid)</PortableProductMonikerRid>

<PgoTerm Condition="'$(PgoInstrument)' == 'true'">-pgo</PgoTerm>
<ArtifactNameSdk>dotnet-sdk-internal$(PgoTerm)</ArtifactNameSdk>
</PropertyGroup>

<PropertyGroup>
Expand Down
3 changes: 2 additions & 1 deletion src/Installer/redist-installer/Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@

<PropertyGroup>
<!-- Any properties that depend on Version and are not in a Target must not be defined in Directory.Build.props as Version won't be available yet. -->
<ArtifactNameWithVersionSdk>$(ArtifactNameSdk)-$(Version)-$(ProductMonikerRid)</ArtifactNameWithVersionSdk>
<PgoTerm Condition="'$(PgoInstrument)' == 'true'">-pgo</PgoTerm>
<ArtifactNameWithVersionSdk>dotnet-sdk-internal$(PgoTerm)-$(Version)-$(ProductMonikerRid)</ArtifactNameWithVersionSdk>
<ArtifactNameWithVersionCombinedHostHostFxrFrameworkSdk>dotnet-sdk$(PgoTerm)-$(Version)-$(ProductMonikerRid)</ArtifactNameWithVersionCombinedHostHostFxrFrameworkSdk>
<!-- Warning: changing the value "ProductBandCombinedHostHostFxrFrameworkSdkName" can only occur on a product-band boundary [CliProductBandVersion],
Changing "ProductBandCombinedHostHostFxrFrameworkSdkName" mid-product-band will break the upgradability of the SDK bundle installer. -->
Expand Down
10 changes: 0 additions & 10 deletions src/Installer/redist-installer/targets/GenerateLayout.targets
Original file line number Diff line number Diff line change
Expand Up @@ -375,16 +375,6 @@
DestinationFolder="$(RedistLayoutPath)/library-packs"
SkipUnchangedFiles="true" />

<!-- From Version.targets in SDK redist -->
<PropertyGroup>
<ArtifactNameSdk>dotnet-toolset-internal</ArtifactNameSdk>
</PropertyGroup>

<!-- From GenerateLayout.targets in SDK redist -->
<PropertyGroup>
<SdkLayoutOutputDirectory>$(ArtifactsBinDir)redist\$(Configuration)\layouts\$(ArtifactNameSdk)\</SdkLayoutOutputDirectory>
</PropertyGroup>

<!-- https://github.com/dotnet/msbuild/issues/5881#issuecomment-802492423 -->
<ItemGroup>
<DotnetToolsetInternalSource Include="$(SdkLayoutOutputDirectory)**\*" />
Expand Down
12 changes: 12 additions & 0 deletions src/Layout/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<Project>

<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)../'))" />

<PropertyGroup>
<OSName Condition="'$(OSName)' == '' AND $([MSBuild]::IsOSPlatform('Windows'))">win</OSName>
<OSName Condition="'$(OSName)' == '' AND $([MSBuild]::IsOSPlatform('OSX'))">osx</OSName>
<OSName Condition="'$(OSName)' == '' ">linux</OSName>
<Rid Condition="'$(Rid)' == ''">$(OSName)-$(Architecture)</Rid>
</PropertyGroup>

</Project>
3 changes: 0 additions & 3 deletions src/Layout/redist/redist.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,11 @@
</PropertyGroup>

<Import Project="$(RepoRoot)src\Tasks\sdk-tasks\sdk-tasks.InTree.targets" />
<Import Project="targets\GetRuntimeInformation.targets" />
<Import Project="targets\Version.targets" />
<Import Project="targets\BundledSdks.targets" />
<Import Project="targets\BundledTools.targets" />
<Import Project="targets\PublishDotnetWatch.targets" />
<Import Project="targets\GenerateLayout.targets" />
<Import Project="targets\OverlaySdkOnLKG.targets" Condition="'$(DotNetBuild)' != 'true'" />
<Import Project="targets\MSBuildExtensions.targets" />

<ItemGroup>
<PackageReference Include="NuGet.Build.Tasks" />
Expand Down
37 changes: 36 additions & 1 deletion src/Layout/redist/targets/BundledSdks.targets
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project>

<ItemGroup>
<BundledSdk Include="NuGet.Build.Tasks.Pack" Version="$(NuGetBuildTasksPackPackageVersion)" />
<BundledSdk Include="Microsoft.NET.Sdk.WindowsDesktop" Version="$(MicrosoftNETSdkWindowsDesktopPackageVersion)" Condition="'$(DotNetBuildSourceOnly)' != 'true'" />
Expand All @@ -12,4 +13,38 @@
<BundledSdk Include="Microsoft.SourceLink.GitLab" Version="$(MicrosoftSourceLinkGitLabVersion)" />
<BundledSdk Include="Microsoft.SourceLink.Bitbucket.Git" Version="$(MicrosoftSourceLinkBitBucketGitVersion)" />
</ItemGroup>

<!-- Restore bundled sdks -->
<ItemGroup>
<PackageDownload Include="@(BundledSdk)" Version="[%(Version)]" />
</ItemGroup>

<Target Name="PublishSdks">
<ItemGroup>
<BundledSdk SdkLayoutDirectory="$(OutputPath)Sdks\%(Identity)\"
PackageNameLowercase="$([System.String]::new('%(Identity)').ToLowerInvariant())" />
<BundledSdk NuPkgPath="$(NuGetPackageRoot)%(PackageNameLowercase)\%(Version)\" />
</ItemGroup>

<Error Text="Bundled SDK has not been restored yet: '%(BundledSdk.NuPkgPath)%(BundledSdk.PackageNameLowercase).nuspec'"
Condition="!Exists('%(BundledSdk.NuPkgPath)%(BundledSdk.PackageNameLowercase).nuspec')" />

<ItemGroup>
<SdkContent Include="%(BundledSdk.NuPkgPath)**\*"
Exclude="%(BundledSdk.NuPkgPath)Icon.png;
%(BundledSdk.NuPkgPath)%(BundledSdk.PackageNameLowercase).nuspec;
%(BundledSdk.NuPkgPath)%(BundledSdk.PackageNameLowercase).%(BundledSdk.Version).nupkg;
%(BundledSdk.NuPkgPath)%(BundledSdk.PackageNameLowercase).%(BundledSdk.Version).nupkg.sha512;
%(BundledSdk.NuPkgPath)**\*.nupkg.metadata;
%(BundledSdk.NuPkgPath)**\*.signature.p7s"
SdkLayoutDirectory="%(BundledSdk.SdkLayoutDirectory)" />
</ItemGroup>

<Copy SourceFiles="@(SdkContent)"
DestinationFiles="@(SdkContent->'%(SdkLayoutDirectory)%(RecursiveDir)%(FileName)%(Extension)')"
SkipUnchangedFiles="true" />

<Message Text="Copied Sdk '%(BundledSdk.Identity)' from '%(BundledSdk.NuPkgPath)' to '%(BundledSdk.SdkLayoutDirectory)'." Importance="High" />
</Target>

</Project>
4 changes: 3 additions & 1 deletion src/Layout/redist/targets/BundledTools.targets
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project>

<ItemGroup>
<BundledTools Include="MSBuild;
dotnet;
Expand All @@ -9,4 +10,5 @@
tool_cli;
redist;" />
</ItemGroup>

</Project>
62 changes: 20 additions & 42 deletions src/Layout/redist/targets/GenerateLayout.targets
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,17 @@

<Target Name="PublishPortableRuntimeIdentifierGraph"
BeforeTargets="Build">

<Copy SourceFiles="$(NuGetPackageRoot)/microsoft.netcore.platforms/$(MicrosoftNETCorePlatformsPackageVersion)/runtime.json"
DestinationFiles="$(OutputPath)RuntimeIdentifierGraph.json"
SkipUnchangedFiles="true" />

<Copy SourceFiles="$(NuGetPackageRoot)/microsoft.netcore.platforms/$(MicrosoftNETCorePlatformsPackageVersion)/PortableRuntimeIdentifierGraph.json"
DestinationFolder="$(OutputPath)"
SkipUnchangedFiles="true" />

</Target>

<Target Name="PublishVersionFile"
BeforeTargets="Build">

<WriteLinesToFile File="$(OutputPath)/.toolsetversion"
Lines="$(SourceRevisionId);$(Version);$(Rid)"
Overwrite="true" />
Expand All @@ -35,8 +32,6 @@
The resolution of the product version (https://github.com/dotnet/sdk/blob/main/src/Cli/Microsoft.DotNet.Cli.Utils/DotnetFiles.cs#L21)
then need the version file there as well. -->
<Copy SourceFiles="$(OutputPath)/.version" DestinationFiles="$(BaseOutputPath)$(Configuration)/.version" SkipUnchangedFiles="true" />


</Target>

<Target Name="PublishRoslyn"
Expand All @@ -57,7 +52,7 @@

<Target Name="PublishNETAnalyzers"
BeforeTargets="Build;PublishNetSdk">
<PropertyGroup>
<PropertyGroup>
<AnalyzerAssembliesDirectory>$(ArtifactsBinDir)$(Configuration)\Sdks\Microsoft.NET.Sdk\analyzers</AnalyzerAssembliesDirectory>
<AnalyzerTargetsDirectory>$(AnalyzerAssembliesDirectory)\build</AnalyzerTargetsDirectory>
<AnalyzerConfigDirectory>$(AnalyzerTargetsDirectory)\config</AnalyzerConfigDirectory>
Expand Down Expand Up @@ -123,12 +118,27 @@
<Copy SourceFiles="@(DotnetFormatConfigFiles)" DestinationFiles="@(DotnetFormatConfigFiles->'$(DotnetFormatDestinationDirectory)/%(RecursiveDir)%(Filename)%(Extension)')" />
</Target>

<Target Name="PublishMSBuildExtensions"
DependsOnTargets="GenerateMSBuildExtensions"
BeforeTargets="Build">
<Target Name="PublishMSBuildExtensions">
<PropertyGroup>
<MSBuildExtensionsPackageName>Microsoft.NET.Build.Extensions</MSBuildExtensionsPackageName>
<MSBuildExtensionsVersionSubfolder>Current</MSBuildExtensionsVersionSubfolder>
<MSBuildExtensionsSourceRoot>$(ArtifactsBinDir)$(Configuration)\Sdks\$(MSBuildExtensionsPackageName)</MSBuildExtensionsSourceRoot>
</PropertyGroup>

<ItemGroup>
<!-- Include MSBuild imports that are checked into repo -->
<MSBuildExtensionsContent Include="$(MSBuildProjectDirectory)/MSBuildImports/**/*" />
<MSBuildExtensionsContent Include="$(MSBuildExtensionsSourceRoot)\msbuildExtensions\**\*.*" />

<!-- Don't include .NET Framework MS.NET.Build.Extensions tasks in CLI layout -->
<MSBuildExtensionsContent Remove="$(MSBuildExtensionsSourceRoot)\msbuildExtensions\Microsoft\Microsoft.NET.Build.Extensions\tools\net472\**" />

<MSBuildExtensionsContent Include="$(MSBuildExtensionsSourceRoot)\msbuildExtensions-ver\**\*.*"
DeploymentSubpath="$(MSBuildExtensionsVersionSubfolder)/" />
</ItemGroup>

<Copy SourceFiles="@(MSBuildExtensionsContent)"
DestinationFiles="@(MSBuildExtensionsContent->'$(OutputPath)\%(DeploymentSubpath)\%(RecursiveDir)%(Filename)%(Extension)')" />

</Target>

<Target Name="PublishNetSdks"
Expand Down Expand Up @@ -396,34 +406,6 @@
AssetPath="%(NuPkgContentForMSBuildExtensionsRelativePaths.Identity)" />
</Target>

<Target Name="PublishSdks"
AfterTargets="Build">
<ItemGroup>
<SdksToBundle Include="targets\RestoreDependency.proj">
<Properties>
NuGetPackageRoot=$(NuGetPackageRoot);
SdkLayoutDirectory=$(OutputPath)/Sdks/%(BundledSdk.Identity);
DependencyPackageName=%(BundledSdk.Identity);
DependencyPackageVersion=%(BundledSdk.Version);
PreviousStageDirectory=$(PreviousStageDirectory)
</Properties>
</SdksToBundle>
</ItemGroup>

<MSBuild
BuildInParallel="False"
Projects="@(SdksToBundle)">
</MSBuild>

<!-- The WPF SDK .nupkg includes some files in the root that we don't want to bundle, so delete them -->
<ItemGroup>
<SDKFilesToDelete Include="$(OutputPath)/Sdks/Microsoft.NET.Sdk.Wpf/*" />
<SDKFilesToDelete Include="$(OutputPath)/Sdks/**/*.nupkg.metadata" />
<SDKFilesToDelete Include="$(OutputPath)/Sdks/**/*.signature.p7s" />
</ItemGroup>
<Delete Files="@(SDKFilesToDelete)" />
</Target>

<Target Name="ChmodPublishDir"
AfterTargets="GenerateCliRuntimeConfigurationFiles"
Condition=" '$(OSName)' != 'win' ">
Expand Down Expand Up @@ -487,10 +469,6 @@
RetargetTools;
GetDotnetWatchRedistOutputDirectory"
AfterTargets="Build">
<PropertyGroup>
<SdkLayoutOutputDirectory>$(BaseOutputPath)$(Configuration)\layouts\$(ArtifactNameSdk)</SdkLayoutOutputDirectory>
</PropertyGroup>

<ItemGroup>
<ToolsetLayoutInput Include="$(OutputPath)/**/*" />
<!-- Include redist outputs published by dotnet-watch.csproj build. -->
Expand Down
15 changes: 0 additions & 15 deletions src/Layout/redist/targets/GetRuntimeInformation.targets

This file was deleted.

32 changes: 0 additions & 32 deletions src/Layout/redist/targets/MSBuildExtensions.targets

This file was deleted.

6 changes: 3 additions & 3 deletions src/Layout/redist/targets/OverlaySdkOnLKG.targets
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<Project ToolsVersion="14.0" DefaultTargets="Test">
<Project>

<Target Name="OverlaySdkOnLKG" AfterTargets="Build" DependsOnTargets="GenerateLayout">
<PropertyGroup>
<RedistLayoutPath>$(BaseOutputPath)$(Configuration)\dotnet\</RedistLayoutPath>
Expand Down Expand Up @@ -111,7 +112,6 @@
WorkloadManifestPath="%(MonoToolchainCurrentWorkloadManifests.FullPath)" />
</Target>


<Target Name="PublishTestWorkloads"
AfterTargets="OverlaySdkOnLKG">
<PropertyGroup>
Expand All @@ -134,6 +134,6 @@

<Copy SourceFiles="@(WorkloadPackContent)"
DestinationFiles="@(WorkloadPackContent->'$(RedistLayoutPath)\packs\%(RecursiveDir)%(Filename)%(Extension)')" />

</Target>

</Project>
18 changes: 8 additions & 10 deletions src/Layout/redist/targets/PublishDotnetWatch.targets
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
<Project>

<Target Name="GetDotnetWatchRedistOutputDirectory">
<PropertyGroup>
<DotnetWatchRedistOutputDirectory>$(ArtifactsDir)bin\redist\$(Configuration)\dotnet\sdk\$(Version)\DotnetTools\dotnet-watch\</DotnetWatchRedistOutputDirectory>
<DotnetWatchRedistOutputSubdirectory>$(Version)\tools\$(SdkTargetFramework)\any\</DotnetWatchRedistOutputSubdirectory>
</PropertyGroup>
</Target>

<Target Name="_PublishDotnetWatchToRedist_Inputs">
<Target Name="PublishDotnetWatchToRedist" DependsOnTargets="GetDotnetWatchRedistOutputDirectory">
<ItemGroup>
<_DotnetWatchBuildOutput Include="$(ArtifactsDir)bin\dotnet-watch\$(Configuration)\$(SdkTargetFramework)\**"/>

Expand All @@ -26,15 +27,12 @@
'%(Filename)' != 'Microsoft.CodeAnalysis.CSharp.resources') or
$([MSBuild]::ValueOrDefault('%(FullPath)', '').Contains('BuildHost'))" />
</ItemGroup>
</Target>

<Target Name="PublishDotnetWatchToRedist"
DependsOnTargets="GetDotnetWatchRedistOutputDirectory;_PublishDotnetWatchToRedist_Inputs">

<Copy SourceFiles="@(_DotnetWatchInputFile)" DestinationFiles="@(_DotnetWatchInputFile->'$(DotnetWatchRedistOutputDirectory)$(DotnetWatchRedistOutputSubdirectory)%(RecursiveDir)%(Filename)%(Extension)')" SkipUnchangedFiles="true" />

<ItemGroup>
<FileWrites Include="@(_DotnetWatchInputFile->'$(DotnetWatchRedistOutputDirectory)$(DotnetWatchRedistOutputSubdirectory)%(RecursiveDir)%(Filename)%(Extension)')" />
</ItemGroup>
<Copy SourceFiles="@(_DotnetWatchInputFile)"
DestinationFiles="@(_DotnetWatchInputFile->'$(DotnetWatchRedistOutputDirectory)$(DotnetWatchRedistOutputSubdirectory)%(RecursiveDir)%(Filename)%(Extension)')"
SkipUnchangedFiles="true">
<Output TaskParameter="CopiedFiles" ItemName="FileWrites" />
</Copy>
</Target>

</Project>
Loading

0 comments on commit 2ae52ef

Please sign in to comment.