Skip to content

Commit 7b9e013

Browse files
authored
Stop ilmerging pack (#6697)
1 parent 62c3680 commit 7b9e013

File tree

2 files changed

+7
-185
lines changed

2 files changed

+7
-185
lines changed

src/NuGet.Core/NuGet.Build.Tasks.Pack/NuGet.Build.Tasks.Pack.csproj

Lines changed: 2 additions & 159 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
</ItemGroup>
3939

4040
<ItemGroup>
41-
<PackageReference Include="ILMerge" PrivateAssets="All" Condition=" '$(DotNetBuildSourceOnly)' != 'true' " />
4241
<None Include="$(BuildCommonDirectory)NOTICES.txt" Pack="true" PackagePath="\" />
4342
</ItemGroup>
4443

@@ -63,175 +62,19 @@
6362
</EmbeddedResource>
6463
</ItemGroup>
6564

66-
<Target
67-
Name="PublishAndMergePackNupkg"
68-
AfterTargets="AfterBuild"
69-
Condition="'$(TargetFramework)' != '' AND '$(IsXPlat)' != 'true' AND '$(DotNetBuildSourceOnly)' != 'true' AND '$(BuildingInsideVisualStudio)' != 'true'">
70-
<MSBuild Projects="$(MSBuildProjectFullPath)" Targets="Publish;ILMergeNuGetPack;ILMergeNuGetPackResourcesPerCulture" />
71-
</Target>
72-
73-
<Target Name="ILMergeNuGetPackResourcesPerCulture" DependsOnTargets="Publish">
74-
<ItemGroup>
75-
<_PackResourceDlls Include="$(OutputPath)publish\**\$(AssemblyName).resources.dll" />
76-
</ItemGroup>
77-
<MSBuild Projects="$(MSBuildProjectFullPath)" Targets="ILMergeNuGetPackResources"
78-
Properties="CurrentCulture=%(_PackResourceDlls.RecursiveDir);
79-
BuildProjectReferences=false">
80-
</MSBuild>
81-
</Target>
82-
83-
<Target Name="GetILMergePlatformArg" DependsOnTargets="ResolveReferences">
84-
<ItemGroup>
85-
<ILMergeMscorlibReferencePath Include="@(ReferencePath)" Condition="'%(ReferencePath.Filename)' == 'mscorlib'" />
86-
</ItemGroup>
87-
<PropertyGroup>
88-
<ILMergePlatformDir>@(IlmergeMscorlibReferencePath->'%(RootDir)%(Directory)')</ILMergePlatformDir>
89-
<ILMergePlatformArg>/targetplatform:v4,"$(ILMergePlatformDir.TrimEnd('\/'))"</ILMergePlatformArg>
90-
</PropertyGroup>
91-
</Target>
92-
93-
<Target Name="DetermineILMergeNuGetPackInputsOutputs">
94-
<PropertyGroup>
95-
<PathToBuiltNuGetPack>$(OutputPath)NuGet.Build.Tasks.Pack.dll</PathToBuiltNuGetPack>
96-
<PathToMergedNuGetPack>$(OutputPath)ilmerge\NuGet.Build.Tasks.Pack.dll</PathToMergedNuGetPack>
97-
</PropertyGroup>
98-
<ItemGroup>
99-
<BuildArtifacts Include="$(OutputPath)publish\*.dll" Exclude="$(OutputPath)publish\*Pack.dll" />
100-
</ItemGroup>
101-
<Message Text="$(MSBuildProjectName) -&gt; $(PathToMergedNuGetPack)" Importance="High" />
102-
</Target>
103-
104-
<Target Name="ILMergeNuGetPack"
105-
DependsOnTargets="GetILMergePlatformArg;DetermineILMergeNuGetPackInputsOutputs"
106-
Inputs="$(PathToBuiltNuGetPack);@(BuildArtifacts)"
107-
Outputs="$(PathToMergedNuGetPack)"
108-
Condition="'$(TargetFramework)' != '' AND '$(DotNetBuildSourceOnly)' != 'true' ">
109-
<PropertyGroup>
110-
<ILMergeResultDir>$([System.IO.Path]::GetDirectoryName($(PathToMergedNuGetPack)))</ILMergeResultDir>
111-
</PropertyGroup>
112-
113-
<MakeDir Directories="$(ILMergeResultDir)" />
114-
115-
<PropertyGroup>
116-
<IlmergeCommand>$(ILMergeConsolePath) ^
117-
/out:$(PathToMergedNuGetPack) ^
118-
$(ILMergePlatformArg) ^
119-
/allowDup ^
120-
/lib:$(OutputPath)publish ^
121-
/internalize ^
122-
/xmldocs ^
123-
/log:$(ILMergeResultDir)IlMergeLog.txt</IlmergeCommand>
124-
<IlmergeCommand Condition="'$(SkipSigning)' != 'true' And Exists($(AssemblyOriginatorKeyFile))">$(IlmergeCommand) ^
125-
/delaysign ^
126-
/keyfile:$(AssemblyOriginatorKeyFile)</IlmergeCommand>
127-
<IlmergeCommand>$(IlmergeCommand) ^
128-
$(PathToBuiltNuGetPack) ^
129-
@(BuildArtifacts, ' ')</IlmergeCommand>
130-
<IlmergeCommand Condition=" '$(TargetFramework)' != '$(NETFXTargetFramework)' ">$(IlmergeCommand) ^
131-
/lib:$(PkgMicrosoft_Build_Utilities_Core)\ref\netstandard2.0 ^
132-
/lib:$(PkgMicrosoft_Build_Tasks_Core)\ref\netstandard2.0 ^
133-
/lib:$(PkgMicrosoft_Build_Framework)\ref\netstandard2.0
134-
</IlmergeCommand>
135-
136-
</PropertyGroup>
137-
<Exec Command="$(IlmergeCommand)" ContinueOnError="false" />
138-
</Target>
139-
140-
<Target Name="DetermineILMergeNuGetPackResourcesInputsOutputs">
141-
<PropertyGroup>
142-
<PathToBuiltNuGetPackResource>$(OutputPath)$(CurrentCulture)NuGet.Build.Tasks.Pack.resources.dll</PathToBuiltNuGetPackResource>
143-
<PathToMergedNuGetPackResource>$(OutputPath)ilmerge\$(CurrentCulture)NuGet.Build.Tasks.Pack.resources.dll</PathToMergedNuGetPackResource>
144-
</PropertyGroup>
145-
<ItemGroup>
146-
<ResourceArtifacts Include="$(OutputPath)$(CurrentCulture)NuGet*.resources.dll" Exclude="$(OutputPath)$(CurrentCulture)*Pack.resources.dll" />
147-
</ItemGroup>
148-
<Message Text="$(MSBuildProjectName) -&gt; $(PathToMergedNuGetPackResource)" Importance="High" />
149-
</Target>
150-
151-
<Target Name="ILMergeNuGetPackResources"
152-
DependsOnTargets="GetILMergePlatformArg;DetermineILMergeNuGetPackResourcesInputsOutputs"
153-
Inputs="$(PathToBuiltNuGetPackResource);@(ResourceArtifacts)"
154-
Outputs="$(PathToMergedNuGetPackResource)"
155-
Condition="'$(TargetFramework)' != '' AND '$(CurrentCulture)' != ''">
156-
<PropertyGroup>
157-
<ILMergeResultDir>$([System.IO.Path]::GetDirectoryName($(PathToMergedNuGetPackResource)))</ILMergeResultDir>
158-
</PropertyGroup>
159-
160-
<MakeDir Directories="$(ILMergeResultDir)" />
161-
162-
<PropertyGroup>
163-
<IlmergeCommand>$(ILMergeConsolePath) ^
164-
/out:$(PathToMergedNuGetPackResource) ^
165-
$(ILMergePlatformArg) ^
166-
/allowDup ^
167-
/log ^
168-
/lib:$(OutputPath)\publish ^
169-
/internalize ^
170-
/xmldocs ^
171-
/log:$(ILMergeResultDir)IlMergeLogResources.txt</IlmergeCommand>
172-
<IlmergeCommand Condition="'$(SkipSigning)' != 'true' And Exists($(AssemblyOriginatorKeyFile))">$(IlmergeCommand) ^
173-
/delaysign ^
174-
/keyfile:$(AssemblyOriginatorKeyFile)</IlmergeCommand>
175-
<IlmergeCommand>$(IlmergeCommand) ^
176-
$(PathToBuiltNuGetPackResource) ^
177-
@(ResourceArtifacts, ' ')</IlmergeCommand>
178-
</PropertyGroup>
179-
<Exec Command="$(IlmergeCommand)" ContinueOnError="false" />
180-
</Target>
181-
182-
<!--These targets help get all the DLLs that are packed in the nuspec to be sent for signing.-->
183-
<Target Name="GetIlmergeBuildOutput" DependsOnTargets="ILMergeNuGetPackResourcesPerCulture;_GetDllsInOutputDirectory" Returns="@(DllsToSign)">
184-
<ItemGroup>
185-
<DllsToSign Include="@(DllsInOutputDir)" KeepDuplicates="false" />
186-
</ItemGroup>
187-
</Target>
188-
189-
<Target Name="_GetDllsInOutputDirectory" Returns="@(DllsInOutputDir)">
190-
<ItemGroup>
191-
<DllsInOutputDir Include="$(OutputPath)ilmerge\*.dll" KeepDuplicates="false">
192-
<StrongName>MsSharedLib72</StrongName>
193-
<Authenticode>Microsoft400</Authenticode>
194-
</DllsInOutputDir>
195-
<DllsInOutputDir Include="$(OutputPath)ilmerge\*.xml" KeepDuplicates="false">
196-
<Authenticode>MicrosoftXmlSHA2</Authenticode>
197-
</DllsInOutputDir>
198-
</ItemGroup>
199-
</Target>
200-
201-
<!--These targets help get all the DLLs that are packed in the nuspec to be sent for signing.-->
202-
<Target Name="GetIlmergeSymbolOutput" Returns="@(SymbolsToIndex)">
203-
<ItemGroup>
204-
<SymbolsToIndex Include="$(OutputPath)ilmerge\*.pdb" KeepDuplicates="false" />
205-
</ItemGroup>
206-
</Target>
207-
208-
<Target Name="GetFinalBuildOutput" Returns="@(DllsToIndex)">
209-
<ItemGroup>
210-
<DllsToIndex Include="$(OutputPath)ilmerge\NuGet.Build.Tasks.Pack.dll"/>
211-
</ItemGroup>
212-
</Target>
213-
21465
<Target Name="CreatePackNupkg">
21566
<PropertyGroup>
216-
<!-- Build from source can't use ILMerge and XPLat builds don't run the ILmerge targets. -->
217-
<ILMergeSubpath Condition="'$(DotNetBuildSourceOnly)' != 'true' and '$(IsXPlat)' != 'true'">ilmerge\</ILMergeSubpath>
21867
<PackagePathDir Condition="'$(TargetFramework)' == '$(NETFXTargetFramework)'">Desktop/</PackagePathDir>
21968
<PackagePathDir Condition="'$(TargetFramework)' == '$(NetStandardVersion)'">CoreCLR/</PackagePathDir>
22069
</PropertyGroup>
22170
<ItemGroup>
222-
<TfmSpecificPackageFile Include="$(OutputPath)\$(ILMergeSubpath)NuGet.Build.Tasks.Pack.dll" Condition="'$(DotNetBuildSourceOnly)' != 'true'">
71+
<TfmSpecificPackageFile Include="$(OutputPath)**\NuGet*.resources.dll">
22372
<PackagePath>$(PackagePathDir)</PackagePath>
22473
</TfmSpecificPackageFile>
225-
<TfmSpecificPackageFile Include="$(OutputPath)\$(ILMergeSubpath)**\NuGet*.resources.dll" Exclude="$(OutputPath)\$(ILMergeSubpath)publish\**\NuGet*.resources.dll">
226-
<PackagePath>$(PackagePathDir)</PackagePath>
227-
</TfmSpecificPackageFile>
228-
<TfmSpecificPackageFile Include="$(OutputPath)\$(ILMergeSubpath)NuGet*.dll" Condition="'$(DotNetBuildSourceOnly)' == 'true'">
74+
<TfmSpecificPackageFile Include="$(OutputPath)*.dll">
22975
<PackagePath>$(PackagePathDir)</PackagePath>
23076
</TfmSpecificPackageFile>
23177
</ItemGroup>
23278
</Target>
23379

234-
<PropertyGroup>
235-
<SymbolTargetsToGetPdbs>GetIlmergeSymbolOutput;GetFinalBuildOutput</SymbolTargetsToGetPdbs>
236-
</PropertyGroup>
23780
</Project>

test/TestUtilities/Test.Utility/TestDotnetCLiUtility.cs

Lines changed: 5 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -316,36 +316,15 @@ private static void CopyPackSdkArtifacts(string artifactsDirectory, string pathT
316316
var targetRuntimeType = "CoreCLR";
317317

318318
var packAssemblyDestinationDirectory = Path.Combine(pathToPackSdk, targetRuntimeType);
319-
// Be smart here so we don't have to call ILMerge in the VS build. It takes ~15s total.
320-
// In VisualStudio, simply use the non il merged version.
321-
bool copiedIlMergedPack = false;
322319

323-
var ilMergedPackDirectoryPath = Path.Combine(packProjectCoreArtifactsDirectory.FullName, "ilmerge");
324-
if (Directory.Exists(ilMergedPackDirectoryPath))
320+
foreach (var assembly in packProjectCoreArtifactsDirectory.EnumerateFiles("*.dll"))
325321
{
326-
var packFileName = packProjectName + ".dll";
327-
// Only use the il merged assembly if it's newer than the build.
328-
DateTime packAssemblyCreationDate = File.GetLastWriteTimeUtc(Path.Combine(packProjectCoreArtifactsDirectory.FullName, packFileName));
329-
DateTime ilMergedPackAssemblyCreationDate = File.GetLastWriteTimeUtc(Path.Combine(ilMergedPackDirectoryPath, packFileName));
330-
if (ilMergedPackAssemblyCreationDate > packAssemblyCreationDate)
331-
{
332-
copiedIlMergedPack = true;
333-
File.Copy(sourceFileName: Path.Combine(packProjectCoreArtifactsDirectory.FullName, "ilmerge", packFileName),
334-
destFileName: Path.Combine(packAssemblyDestinationDirectory, packFileName),
335-
overwrite: true);
336-
}
322+
File.Copy(
323+
sourceFileName: assembly.FullName,
324+
destFileName: Path.Combine(packAssemblyDestinationDirectory, assembly.Name),
325+
overwrite: true);
337326
}
338327

339-
if (!copiedIlMergedPack)
340-
{
341-
foreach (var assembly in packProjectCoreArtifactsDirectory.EnumerateFiles("*.dll"))
342-
{
343-
File.Copy(
344-
sourceFileName: assembly.FullName,
345-
destFileName: Path.Combine(packAssemblyDestinationDirectory, assembly.Name),
346-
overwrite: true);
347-
}
348-
}
349328
// Copy the pack targets
350329
var packTargetsSource = Path.Combine(packProjectCoreArtifactsDirectory.FullName, packTargetsName);
351330
var targetsDestination = Path.Combine(pathToPackSdk, "build", packTargetsName);

0 commit comments

Comments
 (0)