-
Notifications
You must be signed in to change notification settings - Fork 576
[msbuild] Build the MSBuild task assemblies for netstandard2.0. #7706
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
92f5548
2bbc502
4a6c15e
00cd4e2
fee8b31
c354658
9125ba9
3667af0
14921d8
9eef111
7315695
db07b40
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
| <PropertyGroup> | ||
| <CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies> | ||
| </PropertyGroup> | ||
|
|
||
| <ItemGroup> | ||
| <PackageReference Include="ILRepack" Version="2.0.18" /> | ||
| </ItemGroup> | ||
|
|
||
| <Target Name="ILRepack" BeforeTargets="CopyFilesToOutputDirectory" Inputs="@(IntermediateAssembly -> '%(FullPath)')" Outputs="$(IntermediateOutputPath)ilrepack.txt" Returns="@(MergedAssemblies)" Condition="Exists(@(IntermediateAssembly -> '%(FullPath)')) And '$(ILRepack)' != 'false'"> | ||
| <ItemGroup> | ||
| <NetstandardPath Include="@(ReferencePath -> '%(RootDir)%(Directory)')" Condition="'%(FileName)%(Extension)' == 'netstandard.dll'" /> | ||
| </ItemGroup> | ||
| <PropertyGroup> | ||
| <NetstandardDirectory>@(NetstandardPath)</NetstandardDirectory> | ||
| </PropertyGroup> | ||
| <!-- The assemblies are in a very different place when building for netstandard2.0, which means we need different logic to find them too --> | ||
| <ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'"> | ||
| <!-- I don't like to have a hard-coded list of assemblies to merge, but I couldn't find a way to calculate it --> | ||
| <MergedAssemblies Include="@(ReferencePath)" Condition="'%(FileName)' == 'Xamarin.MacDev.Tasks.Core'" /> | ||
| <MergedAssemblies Include="@(ReferencePath)" Condition="'%(FileName)' == 'Xamarin.MacDev.Tasks'" /> | ||
| <MergedAssemblies Include="@(ReferencePath)" Condition="'%(FileName)' == '$(AssemblyName).Core'" /> <!-- Use AssemblyName so that the exact same logic works for both Xamarin.iOS.Tasks.dll and Xamarin.Mac.Tasks.dll --> | ||
| <MergedAssemblies Include="@(ReferencePath)" Condition="'%(FileName)' == 'Xamarin.MacDev'" /> | ||
|
|
||
| <MergedAssemblies Include="$(OutputPath)/Microsoft.Bcl.AsyncInterfaces.dll" /> | ||
| <MergedAssemblies Include="$(OutputPath)/System.Buffers.dll" /> | ||
| <MergedAssemblies Include="$(OutputPath)/System.Memory.dll" /> | ||
| <MergedAssemblies Include="$(OutputPath)/System.Numerics.Vectors.dll" /> | ||
| <MergedAssemblies Include="$(OutputPath)/System.Runtime.CompilerServices.Unsafe.dll" /> | ||
| <MergedAssemblies Include="$(OutputPath)/System.Text.Json.dll" /> | ||
| <MergedAssemblies Include="$(OutputPath)/System.Threading.Tasks.Extensions.dll" /> | ||
| <MergedAssemblies Include="$(OutputPath)/System.Text.Encodings.Web.dll" /> | ||
|
|
||
| <MergedAssemblies Include="@(ReferencePath)" Condition="'%(FileName)' == 'Mono.Posix.NETStandard'" /> | ||
| <MergedAssemblies Include="@(ReferencePath)" Condition="'%(Extension)' == '.dll' And $([System.String]::new('%(FileName)').StartsWith('Mono.Cecil', StringComparison.OrdinalIgnoreCase))" /> | ||
| </ItemGroup> | ||
| <ItemGroup Condition="'$(TargetFramework)' == 'net461'"> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ditto here, |
||
| <MergedAssemblies Include="@(ReferenceCopyLocalPaths)" Condition="'%(Extension)' == '.dll' | ||
| And !$([System.String]::new('%(FileName)').EndsWith('.resources', StringComparison.OrdinalIgnoreCase)) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I usually prefer |
||
| And !$([System.String]::new('%(FileName)').StartsWith('Microsoft.Build.', StringComparison.OrdinalIgnoreCase)) | ||
| And !$([System.String]::new('%(FullPath)').StartsWith('/Library/Frameworks/Mono.framework', StringComparison.OrdinalIgnoreCase))" | ||
| /> | ||
| <MergedAssemblies Include="@(ReferencePath)" Condition="'%(Extension)' == '.dll' And $([System.String]::new('%(FileName)').StartsWith('Mono.Cecil', StringComparison.OrdinalIgnoreCase))" /> | ||
| </ItemGroup> | ||
| <ItemGroup> | ||
| <ReferenceCopyLocalDirs Include="@(ReferenceCopyLocalPaths -> '%(RootDir)%(Directory)')" /> | ||
| <ReferenceCopyLocalPaths Remove="@(MergedAssemblies)" /> | ||
| <LibDir Include="@(ReferenceCopyLocalDirs -> Distinct())" /> | ||
| </ItemGroup> | ||
| <PropertyGroup> | ||
| <ILRepackArgs Condition="'$(AssemblyOriginatorKeyFile)' != ''">/keyfile:"$(AssemblyOriginatorKeyFile)"</ILRepackArgs> | ||
| <ILRepackArgs>$(ILRepackArgs) @(LibDir -> '/lib:"%(Identity)."', ' ')</ILRepackArgs> | ||
| <ILRepackArgs>$(ILRepackArgs) /out:"@(IntermediateAssembly -> '%(FullPath)')"</ILRepackArgs> | ||
| <ILRepackArgs>$(ILRepackArgs) "@(IntermediateAssembly -> '%(FullPath)')"</ILRepackArgs> | ||
| <ILRepackArgs>$(ILRepackArgs) @(MergedAssemblies -> '"%(FullPath)"', ' ')</ILRepackArgs> | ||
| <ILRepackArgs>$(ILRepackArgs) "/lib:$(NetstandardDirectory)"</ILRepackArgs> <!-- This is needed for ilrepack to find netstandard.dll, which is referenced by the System.Text.Json assembly --> | ||
| </PropertyGroup> | ||
| <Exec Command=""$(ILRepack)" $(ILRepackArgs)" WorkingDirectory="$(MSBuildProjectDirectory)\$(OutputPath)" StandardErrorImportance="high" StandardOutputImportance="low" ConsoleToMSBuild="true" ContinueOnError="true"> | ||
| <Output TaskParameter="ConsoleOutput" PropertyName="ILRepackOutput" /> | ||
| <Output TaskParameter="ExitCode" PropertyName="ExitCode" /> | ||
| </Exec> | ||
| <Message Importance="high" Text="$(ILRepackOutput)" Condition="'$(ExitCode)' != '0'" /> | ||
| <Delete Files="$(IntermediateOutputPath)ilrepack.txt" Condition="'$(ExitCode)' != '0'" /> | ||
| <Touch AlwaysCreate="true" Files="$(IntermediateOutputPath)ilrepack.txt" Condition="'$(ExitCode)' == '0'" /> | ||
| <Error Text="$(ILRepackOutput)" Condition="'$(ExitCode)' != '0' And '$(ContinueOnError)' != 'true'" /> | ||
| <Delete Files="@(MergedAssemblies -> '$(MSBuildProjectDirectory)\$(OutputPath)%(Filename)%(Extension)')" Condition="Exists('$(MSBuildProjectDirectory)\$(OutputPath)%(Filename)%(Extension)')" /> | ||
| </Target> | ||
| </Project> | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be
$(TargetFramework.StartsWith('netstandard'))instead to make it more future-proof?