WasmLinkerTest.csproj 3.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <Project Sdk="Microsoft.NET.Sdk">
  2. <PropertyGroup>
  3. <TargetFramework>$(DefaultNetCoreTargetFramework)</TargetFramework>
  4. <RuntimeIdentifier>browser-wasm</RuntimeIdentifier>
  5. <SelfContained>true</SelfContained>
  6. </PropertyGroup>
  7. <ItemGroup>
  8. <Reference Include="Microsoft.AspNetCore.Metadata" />
  9. <Reference Include="Microsoft.AspNetCore.Authorization" />
  10. <Reference Include="Microsoft.AspNetCore.Components.Authorization" />
  11. <Reference Include="Microsoft.AspNetCore.Components" />
  12. <Reference Include="Microsoft.AspNetCore.Components.Forms" />
  13. <Reference Include="Microsoft.AspNetCore.Components.Web" />
  14. <Reference Include="Microsoft.AspNetCore.Components.WebAssembly" />
  15. <Reference Include="Microsoft.JSInterop" />
  16. <Reference Include="Microsoft.JSInterop.WebAssembly" />
  17. </ItemGroup>
  18. <Target Name="ILLinkTrimWasmProjects" DependsOnTargets="ResolveReferences" AfterTargets="Build" Condition="'$(DotNetBuildFromSource)' != 'true' AND '$(SkipTestBuild)' != 'true'">
  19. <PropertyGroup>
  20. <LibrariesTrimmedArtifactsPath>$(TargetDir)wasm-linked\</LibrariesTrimmedArtifactsPath>
  21. <!-- Link all assemblies -->
  22. <ILLinkArgs>$(ILLinkArgs) -c link</ILLinkArgs>
  23. <ILLinkArgs>$(ILLinkArgs) -u link</ILLinkArgs>
  24. <ILLinkArgs>$(ILLinkArgs) -b true</ILLinkArgs>
  25. <ILLinkArgs Condition="'$(GenerateLinkerWarningSuppressions)' == 'true'">$(ILLinkArgs) --generate-warning-suppressions xml</ILLinkArgs>
  26. </PropertyGroup>
  27. <ItemGroup>
  28. <RootAssemblies Include="@(ReferencePath->HasMetadata('ProjectPath'))" RootMode="visible" />
  29. <_ILLinkSuppressionFile Include="$([System.IO.Path]::GetDirectoryName($([System.String]::new('%(RootAssemblies.ProjectPath)'))))\%(FileName).WarningSuppressions.xml"
  30. SuppressionFileName="%(FileName).WarningSuppressions" />
  31. <ILLinkSuppressionFile Condition="Exists(%(_ILLinkSuppressionFile.Identity))" Include="%(_ILLinkSuppressionFile.Identity)" />
  32. </ItemGroup>
  33. <PropertyGroup>
  34. <ILLinkArgs Condition="'$(GenerateLinkerWarningSuppressions)' != 'true' AND @(ILLinkSuppressionFile->Count()) != 0">$(ILLinkArgs) --link-attributes @(ILLinkSuppressionFile->'%(FullPath)', ' --link-attributes ')</ILLinkArgs>
  35. </PropertyGroup>
  36. <!--
  37. When running from Desktop MSBuild, DOTNET_HOST_PATH is not set.
  38. In this case, explicitly specify the path to the dotnet host.
  39. -->
  40. <PropertyGroup Condition=" '$(DOTNET_HOST_PATH)' == '' ">
  41. <!-- This is defined when building in Visual Studio. -->
  42. <_DotNetHostDirectory>$(NetCoreRoot)</_DotNetHostDirectory>
  43. <_DotNetHostFileName>$([System.IO.Path]::GetFileName('$(DotNetTool)'))</_DotNetHostFileName>
  44. </PropertyGroup>
  45. <ILLink
  46. AssemblyPaths=""
  47. RootAssemblyNames="@(RootAssemblies)"
  48. OutputDirectory="$(LibrariesTrimmedArtifactsPath)"
  49. ReferenceAssemblyPaths="@(RuntimePackAsset);@(ReferencePath->WithMetadataValue('ExternallyResolved', 'true'))"
  50. ExtraArgs="$(ILLinkArgs)"
  51. ToolExe="$(_DotNetHostFileName)"
  52. ToolPath="$(_DotNetHostDirectory)" />
  53. <ItemGroup Condition="'$(GenerateLinkerWarningSuppressions)' == 'true'">
  54. <_UpdatedILLinkSuppressionFile Include="$(LibrariesTrimmedArtifactsPath)\*.WarningSuppressions.xml" />
  55. <_UpdatedILLinkSuppressionFile SourcePath="%(FullPath)" />
  56. </ItemGroup>
  57. <JoinItems
  58. Left="@(_ILLinkSuppressionFile)"
  59. Right="@(_UpdatedILLinkSuppressionFile)"
  60. LeftMetadata="*"
  61. RightMetadata="SourcePath"
  62. LeftKey="SuppressionFileName"
  63. RightKey="FileName"
  64. ItemSpecToUse="Left">
  65. <Output TaskParameter="JoinResult" ItemName="_ILLinkFileToUpdate" />
  66. </JoinItems>
  67. <Copy
  68. SourceFiles="%(_ILLinkFileToUpdate.SourcePath)"
  69. DestinationFiles="%(_ILLinkFileToUpdate.FullPath)"
  70. OverwriteReadOnlyFiles="true"
  71. Condition="'$(GenerateLinkerWarningSuppressions)' == 'true'" />
  72. </Target>
  73. </Project>