peters / ILRepack.MSBuild.Task

MSBuild task for ILRepack which is an open-source alternative to ILMerge.
Other
83 stars 31 forks source link

Packed dlls do not work with Blazor #45

Open frankabbruzzese opened 4 years ago

frankabbruzzese commented 4 years ago

I configured a client Blazor project with:

<Project Sdk="Microsoft.NET.Sdk.Web">
  <PropertyGroup>
    <TargetFramework>netstandard2.1</TargetFramework>
    <RazorLangVersion>3.0</RazorLangVersion>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="ILRepack.MSBuild.Task" Version="2.0.13" PrivateAssets="All" />
    <PackageReference Include="Microsoft.AspNetCore.Blazor" Version="3.2.0-preview1.20073.1" />
    <PackageReference Include="Microsoft.AspNetCore.Blazor.Build" Version="3.2.0-preview1.20073.1" PrivateAssets="all" />
    <PackageReference Include="Microsoft.AspNetCore.Blazor.DevServer" Version="3.2.0-preview1.20073.1" PrivateAssets="all" />
    <PackageReference Include="Microsoft.AspNetCore.Blazor.HttpClient" Version="3.2.0-preview1.20073.1" />
  </ItemGroup>
  <ItemGroup>
    <ProjectReference Include="..\..\MvcControlsToolkit.Blazor.Simple\MvcControlsToolkit.Blazor.Simple.csproj" />
    <ProjectReference Include="..\Shared\MvcControlsToolkit.Blazor.Sample.Shared.csproj" />
  </ItemGroup>
  <Target Name="ILRepack" AfterTargets="Build" >
    <PropertyGroup>
      <WorkingDirectory>$(MSBuildThisFileDirectory)bin\$(Configuration)\$(TargetFramework)</WorkingDirectory>
    </PropertyGroup>
    <ItemGroup>
      <InputAssemblies Include="MvcControlsToolkit.Blazor.Sample.Client.dll" />
      <InputAssemblies Include="MvcControlsToolkit.Core.DataAnnotations.dll" />
      <InputAssemblies Include="MvcControlsToolkit.Blazor.DataAnnotations.dll" />
      <InputAssemblies Include="MvcControlsToolkit.Blazor.Metadata.dll" />
      <InputAssemblies Include="MvcControlsToolkit.Blazor.Simple.dll" />
    </ItemGroup>

    <Message Text="MERGING: @(InputAssemblies->'%(Filename)') into $(OutputAssembly)" Importance="High" />
    <ILRepack 
            OutputType="$(OutputType)" 
            MainAssembly="$(AssemblyName).dll" 
            OutputAssembly="$(WorkingDirectory)\dist\_framework\_bin\$(AssemblyName).dll" 
            InputAssemblies="@(InputAssemblies)"
            WorkingDirectory="$(WorkingDirectory)" />
  </Target>
</Project>

The pack task runs without errors. However, when running the code in the browser I wet the following error:

WASM: System.IO.FileNotFoundException: Could not load file or assembly 'netstandard, Version=2.1.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies.