Skip to content

Commit f22b60a

Browse files
authored
Packaging cleanup (#6939)
* Packaging cleanup Originally I was just trying to remove mentions of snupkg, but then things got a bit carried away. :) This is trying to remove as much duplication and dead code related to packaging that I can. * Apply code review feedback * Suppress copying indirect references * Remove unwanted bundled files from AutoML * Remove leading slash * Refactor model download * Correct the packaging path of native symbols * Rename NoTargets projects from csproj to proj * Fix build issues around model download and respond to feedback * Remove NoTargets file extension enforcement * Rename proj to CSProj, include in SLN I'd like to ensure all our projects are included in the SLN and don't rely on separate build steps. VS prefers *.csproj in the sln so I renamed things back to csproj. * Respond to PR feedback
1 parent 3855dca commit f22b60a

File tree

76 files changed

+334
-686
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+334
-686
lines changed

Directory.Build.props

+10
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,17 @@
3535
</PropertyGroup>
3636

3737
<PropertyGroup>
38+
<ModelDownloadPath>$(ArtifactsDir)models/</ModelDownloadPath>
3839
<PackageAssetsPath>$(ArtifactsDir)pkgassets/</PackageAssetsPath>
3940
<PkgDir>$(RepoRoot)pkg/</PkgDir>
41+
42+
<Authors>Microsoft</Authors>
43+
<PackageLicenseExpression>MIT</PackageLicenseExpression>
44+
<PackageProjectUrl>https://dot.net/ml</PackageProjectUrl>
45+
<PackageIcon>mlnetlogo.png</PackageIcon>
46+
<PackageReleaseNotes>https://aka.ms/mlnetreleasenotes</PackageReleaseNotes>
47+
<!-- space separated -->
48+
<PackageTags>ML.NET ML Machine Learning</PackageTags>
4049
</PropertyGroup>
4150

4251
<!-- Need to explicitly set these properties for the -net6_0 or -netfx configurations becuase they are typically based off 'Debug' or 'Release' configs -->
@@ -60,4 +69,5 @@
6069
<!-- Optional: Build symbol packages (.symbols.nupkg) to distribute the PDB containing Source Link -->
6170
<IncludeSymbols>true</IncludeSymbols>
6271
</PropertyGroup>
72+
6373
</Project>

Directory.Build.targets

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project>
33
<Import Project="Sdk.targets" Sdk="Microsoft.DotNet.Arcade.Sdk" />
4+
5+
<Import Condition="'$(IsPackable)' == 'true'" Project="$(RepositoryEngineeringDir)Packaging.targets" />
46

57
<ItemGroup Condition="'$(IsUnitTestProject)' == 'true'">
68
<PackageReference Include="coverlet.msbuild" Version="$(CoverletMsbuildVersion)" PrivateAssets="all" />

Microsoft.ML.sln

+11
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.ML.Samples.OneDal
9696
EndProject
9797
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.ML.Recommender", "src\Microsoft.ML.Recommender\Microsoft.ML.Recommender.csproj", "{C8E1772B-DFD9-4A4D-830D-6AAB1C668BB3}"
9898
EndProject
99+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.ML.DnnImageFeaturizer.ModelRedist", "src\Microsoft.ML.DnnImageFeaturizer.ModelRedist\Microsoft.ML.DnnImageFeaturizer.ModelRedist.csproj", "{39E89702-1A46-4D5B-BA50-530D11309B5E}"
100+
EndProject
99101
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.ML.DnnImageFeaturizer.ResNet18", "src\Microsoft.ML.DnnImageFeaturizer.ResNet18\Microsoft.ML.DnnImageFeaturizer.ResNet18.csproj", "{9222FC9D-599A-49A5-B685-08CC9A5C81D7}"
100102
EndProject
101103
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.ML.DnnImageFeaturizer.AlexNet", "src\Microsoft.ML.DnnImageFeaturizer.AlexNet\Microsoft.ML.DnnImageFeaturizer.AlexNet.csproj", "{6C29AA9B-054B-4762-BEA5-D305B932AA80}"
@@ -818,6 +820,14 @@ Global
818820
{763FF013-8309-4680-A769-B54E7BB99612}.Release|Any CPU.Build.0 = Release|Any CPU
819821
{763FF013-8309-4680-A769-B54E7BB99612}.Release|x64.ActiveCfg = Release|Any CPU
820822
{763FF013-8309-4680-A769-B54E7BB99612}.Release|x64.Build.0 = Release|Any CPU
823+
{39E89702-1A46-4D5B-BA50-530D11309B5E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
824+
{39E89702-1A46-4D5B-BA50-530D11309B5E}.Debug|Any CPU.Build.0 = Debug|Any CPU
825+
{39E89702-1A46-4D5B-BA50-530D11309B5E}.Debug|x64.ActiveCfg = Debug|Any CPU
826+
{39E89702-1A46-4D5B-BA50-530D11309B5E}.Debug|x64.Build.0 = Debug|Any CPU
827+
{39E89702-1A46-4D5B-BA50-530D11309B5E}.Release|Any CPU.ActiveCfg = Release|Any CPU
828+
{39E89702-1A46-4D5B-BA50-530D11309B5E}.Release|Any CPU.Build.0 = Release|Any CPU
829+
{39E89702-1A46-4D5B-BA50-530D11309B5E}.Release|x64.ActiveCfg = Release|Any CPU
830+
{39E89702-1A46-4D5B-BA50-530D11309B5E}.Release|x64.Build.0 = Release|Any CPU
821831
EndGlobalSection
822832
GlobalSection(SolutionProperties) = preSolution
823833
HideSolutionNode = FALSE
@@ -903,6 +913,7 @@ Global
903913
{FB8A8823-CC6C-4C2F-8539-05FBFB7C91CD} = {AED9C836-31E3-4F3F-8ABC-929555D3F3C4}
904914
{AB8D68F1-6C3E-41FD-B0EC-A093E009341D} = {AED9C836-31E3-4F3F-8ABC-929555D3F3C4}
905915
{763FF013-8309-4680-A769-B54E7BB99612} = {AED9C836-31E3-4F3F-8ABC-929555D3F3C4}
916+
{39E89702-1A46-4D5B-BA50-530D11309B5E} = {09EADF06-BE25-4228-AB53-95AE3E15B530}
906917
EndGlobalSection
907918
GlobalSection(ExtensibilityGlobals) = postSolution
908919
SolutionGuid = {41165AF1-35BB-4832-A189-73060F82B01D}

build/publish.proj

-40
This file was deleted.

docs/samples/Microsoft.ML.AutoML.Samples/Microsoft.ML.AutoML.Samples.csproj

+1
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,5 @@
2323
<ItemGroup>
2424
<PackageReference Include="SciSharp.TensorFlow.Redist" Version="$(TensorFlowVersion)" />
2525
</ItemGroup>
26+
2627
</Project>

docs/samples/Microsoft.ML.Samples.GPU/Microsoft.ML.Samples.GPU.csproj

+3-2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
<ProjectReference Include="..\..\..\src\Microsoft.ML.Vision\Microsoft.ML.Vision.csproj" />
2424
<ProjectReference Include="..\..\..\src\Microsoft.ML.ImageAnalytics\Microsoft.ML.ImageAnalytics.csproj" />
2525
<ProjectReference Include="..\..\..\src\Microsoft.ML.Data\Microsoft.ML.Data.csproj" />
26+
<ProjectReference Include="..\..\..\src\Microsoft.ML.DnnImageFeaturizer.ModelRedist\Microsoft.ML.DnnImageFeaturizer.ModelRedist.csproj" />
2627
<ProjectReference Include="..\..\..\src\Microsoft.ML.LightGbm\Microsoft.ML.LightGbm.csproj" />
2728
<ProjectReference Include="..\..\..\src\Microsoft.ML.TensorFlow\Microsoft.ML.TensorFlow.csproj" />
2829
<ProjectReference Include="..\..\..\src\Microsoft.ML.SamplesUtils\Microsoft.ML.SamplesUtils.csproj" />
@@ -54,14 +55,14 @@
5455
</ItemGroup>
5556

5657
<ItemGroup>
57-
<Content Include="$(ArtifactsObjDir)DnnImageModels\ResNet18Onnx\ResNet18.onnx">
58+
<Content Include="$(ModelDownloadPath)\ResNet18Onnx\ResNet18.onnx">
5859
<Link>DnnImageModels\ResNet18Onnx\ResNet18.onnx</Link>
5960
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
6061
</Content>
6162
</ItemGroup>
6263

6364
<ItemGroup>
64-
<Content Include="$(ArtifactsObjDir)DnnImageModels\ResNetPrepOnnx\ResNetPreprocess.onnx">
65+
<Content Include="$(ModelDownloadPath)\ResNetPrepOnnx\ResNetPreprocess.onnx">
6566
<Link>DnnImageModels\ResNetPrepOnnx\ResNetPreprocess.onnx</Link>
6667
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
6768
</Content>

docs/samples/Microsoft.ML.Samples/Microsoft.ML.Samples.csproj

+2-2
Original file line numberDiff line numberDiff line change
@@ -981,14 +981,14 @@
981981
</ItemGroup>
982982

983983
<ItemGroup>
984-
<Content Include="$(ArtifactsObjDir)DnnImageModels\ResNet18Onnx\ResNet18.onnx">
984+
<Content Include="$(ModelDownloadPath)\ResNet18Onnx\ResNet18.onnx">
985985
<Link>DnnImageModels\ResNet18Onnx\ResNet18.onnx</Link>
986986
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
987987
</Content>
988988
</ItemGroup>
989989

990990
<ItemGroup>
991-
<Content Include="$(ArtifactsObjDir)DnnImageModels\ResNetPrepOnnx\ResNetPreprocess.onnx">
991+
<Content Include="$(ModelDownloadPath)\ResNetPrepOnnx\ResNetPreprocess.onnx">
992992
<Link>DnnImageModels\ResNetPrepOnnx\ResNetPreprocess.onnx</Link>
993993
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
994994
</Content>

eng/Build.props

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
</ItemDefinitionGroup>
1010

1111
<ItemGroup>
12-
<ProjectToBuild Include="$(RepoRoot)src/Redist/Microsoft.ML.DnnImageFeaturizer.ModelRedist/Microsoft.ML.DnnImageFeaturizer.ModelRedist.proj" />
1312
<ProjectToBuild Include="$(RepoRoot)src/Native/Native.proj" />
1413
<ProjectToBuild Include="$(RepoRoot)Microsoft.ML.sln" />
1514
</ItemGroup>

eng/Packaging.targets

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<Project>
2+
3+
<ItemGroup>
4+
<Content Include="$(RepositoryEngineeringDir)pkg\mlnetlogo.png" Pack="true" PackagePath="" />
5+
</ItemGroup>
6+
7+
<ItemGroup Condition="'$(IncludeMLNetNotices)' != 'false'">
8+
<Content Include="$(RepoRoot)THIRD-PARTY-NOTICES.TXT" Pack="true" PackagePath="" />
9+
<Content Include="$(RepoRoot)LICENSE" Pack="true" PackagePath=""/>
10+
</ItemGroup>
11+
12+
<PropertyGroup>
13+
<TargetsForTfmSpecificContentInPackage>$(TargetsForTfmSpecificContentInPackage);IncludeAdditionalFilesInPackage;</TargetsForTfmSpecificContentInPackage>
14+
</PropertyGroup>
15+
16+
<Target Name="_IncludeProjectReferencesWithPackAttributeInPackage"
17+
Condition="'@(ProjectReference)' != '' and @(ProjectReference->AnyHaveMetadataValue('Pack', 'true'))"
18+
DependsOnTargets="BuildOnlySettings;ResolveReferences">
19+
<ItemGroup>
20+
<!-- Implements workaround for https://github.com/NuGet/Home/issues/3891 -->
21+
<!-- Add ReferenceCopyLocalPaths for ProjectReferences which are flagged as Pack="true" into the package. -->
22+
<_projectReferenceCopyLocalPaths Include="@(ReferenceCopyLocalPaths->WithMetadataValue('ReferenceSourceTarget', 'ProjectReference')->WithMetadataValue('Pack', 'true'))" />
23+
<TfmSpecificPackageFile Include="@(_projectReferenceCopyLocalPaths)"
24+
PackagePath="$([MSBuild]::ValueOrDefault('%(ReferenceCopyLocalPaths.PackagePath)', '$(BuildOutputTargetFolder)\$(TargetFramework)\'))" />
25+
</ItemGroup>
26+
</Target>
27+
28+
<Target Name="_IncludeRuntimeSpecificAssetsInPackage">
29+
<ItemGroup>
30+
<!-- Add runtime specific assets to the package. -->
31+
<_runtimeFiles Include="$(PackageAssetsPath)$(PackageId)\runtimes\**\*%(NativeAssemblyReference.Identity)*" />
32+
<TfmSpecificPackageFile Include="%(_runtimeFiles.Identity)" PackagePath="runtimes/%(_runtimeFiles.RecursiveDir)" TargetFramework="" />
33+
</ItemGroup>
34+
</Target>
35+
36+
<Target Name="IncludeAdditionalFilesInPackage" DependsOnTargets="_IncludeProjectReferencesWithPackAttributeInPackage;_IncludeRuntimeSpecificAssetsInPackage">
37+
<ItemGroup>
38+
<!-- PDBs must be specified as TfmSpecificDebugSymbolsFile with a *rooted* TargetPath instead of PackagePath. -->
39+
<TfmSpecificDebugSymbolsFile Include="@(TfmSpecificPackageFile->WithMetadataValue('Extension', '.pdb'))"
40+
TargetPath="/%(TfmSpecificPackageFile.PackagePath)%(Filename)%(Extension)"
41+
TargetFramework="$(TargetFramework)" />
42+
<!-- Remove symbols from the file list. -->
43+
<TfmSpecificPackageFile Remove="@(TfmSpecificPackageFile->WithMetadataValue('Extension', '.pdb'))" />
44+
</ItemGroup>
45+
</Target>
46+
47+
</Project>

eng/Signing.props

-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
11
<Project>
2-
<ItemGroup>
3-
<ItemsToSign Include="$(ArtifactsPackagesDir)**\*.snupkg" />
4-
<FileExtensionSignInfo Include="*.snupkg" CertificateName="NuGet" />
5-
</ItemGroup>
6-
72
<PropertyGroup>
83
<UseDotNetCertificate>true</UseDotNetCertificate>
94
</PropertyGroup>

eng/pkg/Pack.props

-85
This file was deleted.

global.json

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"msbuild-sdks": {
1616
"Microsoft.DotNet.Arcade.Sdk": "9.0.0-beta.24102.4",
1717
"Microsoft.DotNet.Helix.Sdk": "9.0.0-beta.24102.4",
18+
"Microsoft.Build.NoTargets": "3.7.0",
1819
"Microsoft.Build.Traversal": "3.2.0",
1920
"Microsoft.SourceLink.GitHub": "1.1.0-beta-20206-02",
2021
"Microsoft.SourceLink.Common": "1.1.0-beta-20206-02"

src/Directory.Build.props

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<Import Project="..\Directory.Build.props" />
44

55
<PropertyGroup>
6-
<GenerateDocumentationFile>true</GenerateDocumentationFile>
6+
<GenerateDocumentationFile Condition="'$(UsingMicrosoftNoTargetsSdk)' != 'true'">true</GenerateDocumentationFile>
77
<!-- Not all types and members have XML docs yet.
88
When you are ready to tackle adding them, remove <NoWarn>
99
below, and when you get clean, also remove <WarningsNotAsErrors>
@@ -24,7 +24,7 @@
2424

2525
<ItemGroup>
2626
<ProjectReference
27-
Condition="'$(UseMLCodeAnalyzer)' != 'false' and '$(MSBuildProjectExtension)' == '.csproj'"
27+
Condition="'$(UseMLCodeAnalyzer)' != 'false' and '$(MSBuildProjectExtension)' == '.csproj' and '$(UsingMicrosoftNoTargetsSdk)' != 'true'"
2828
Include="$(MSBuildThisFileDirectory)\..\tools-local\Microsoft.ML.InternalCodeAnalyzer\Microsoft.ML.InternalCodeAnalyzer.csproj">
2929
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
3030
<OutputItemType>Analyzer</OutputItemType>

src/Directory.Build.targets

-24
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,6 @@
22

33
<Import Project="..\Directory.Build.targets" />
44

5-
<Target Name="PreparePackageAssets" Condition="'$(CopyPackageAssets)' == 'true'"
6-
AfterTargets="Build">
7-
8-
<ItemGroup Condition="'$(IncludeInPackage)' != ''">
9-
<PackageAsset Include="$(TargetPath)"
10-
RelativePath="$(IncludeInPackage)\lib\$(TargetFramework)" />
11-
<PackageAsset Include="@(DebugSymbolsProjectOutputGroupOutput)"
12-
RelativePath="$(IncludeInPackage)\lib\$(TargetFramework)" />
13-
<PackageAsset Include="@(DocumentationProjectOutputGroupOutput)"
14-
RelativePath="$(IncludeInPackage)\lib\$(TargetFramework)" />
15-
</ItemGroup>
16-
17-
<ItemGroup Condition="'$(IncludeAnalyzerInPackage)' != ''">
18-
<PackageAsset Include="$(TargetPath)"
19-
RelativePath="$(IncludeAnalyzerInPackage)\analyzers\dotnet\cs" />
20-
<PackageAsset Include="@(DebugSymbolsProjectOutputGroupOutput)"
21-
RelativePath="$(IncludeAnalyzerInPackage)\analyzers\dotnet\cs" />
22-
</ItemGroup>
23-
24-
<Copy SourceFiles="@(PackageAsset)"
25-
DestinationFolder="$(PackageAssetsPath)%(PackageAsset.RelativePath)" />
26-
27-
</Target>
28-
295
<!-- API Compat -->
306
<PropertyGroup Condition="'$(IsPackable)' == 'true'">
317
<!-- Enable API compat for any packages unless they've set EnablePackageValidation -->

0 commit comments

Comments
 (0)