dotnet / aspnetcore

ASP.NET Core is a cross-platform .NET framework for building modern cloud-based web applications on Windows, Mac, or Linux.
https://asp.net
MIT License
35.15k stars 9.92k forks source link

Get rid of BlazorDebugProxy in release builds #25102

Closed Pethical closed 3 years ago

Pethical commented 4 years ago

Is your feature request related to a problem? Please describe.

I am trying to publish a blazor webassembly app (server hosted with web api), but I can't get rid of the BlazorDebugProxy directory. This is a very large directory and seems to be totally unwanted in production environments.

Describe the solution you'd like

I would like a switch/paraméter in the project file, what can ignore this files from the release builds, eg: <BlazorDebugProxyEnabled>true|false</BlazorDebugProxyEnabled> or simple ignore it without any switch when the configuration is release.

Regards, Peter

ghost commented 4 years ago

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

njannink commented 4 years ago

Since this is in triage for .Net 5, is there a workaround for this for .NetCore 3.1?

captainsafia commented 3 years ago

This issue is in the backlog for now. We'll re-evaluate if more people express interest in this.

As for work-arounds, I'd recommend adding a custom MSBuild task to prune out the directory after publish when under Release configuration.

vladyslav-burylov commented 3 years ago

if you don't use ClickOnce and publishing to the file system, you can use something like:

<!-- common.props - include in your *.csproj: <Import Project="$(relative_path)\common.props" /> -->
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <!-- https://github.com/dotnet/aspnetcore/issues/25102 -->
    <PublishProtocolProviderTargets>RemoveBlazorDebugProxy;$(PublishProtocolProviderTargets)</PublishProtocolProviderTargets>
  </PropertyGroup>
  <Target Name="RemoveBlazorDebugProxy" />
  <Target Name="RemoveBlazorDebugProxy" Condition=" '$(Configuration)' == 'Release' ">
    <RemoveDir Directories="$(PublishDir)\BlazorDebugProxy" />
  </Target>
</Project>

Hints: https://github.com/dotnet/sdk/search?q=PublishProtocolProviderTargets

menees commented 3 years ago

It's probably ok to close this issue because BlazorWebAssemblyOmitDebugProxyOutput solves the original request in .NET 5. I found this answer on StackOverflow, and it works when I add the following to my Server project:

<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
  <BlazorWebAssemblyOmitDebugProxyOutput>true</BlazorWebAssemblyOmitDebugProxyOutput>
</PropertyGroup>
captainsafia commented 3 years ago

@menees Good find! Thanks for sharing the solution. I actually no idea we had this condition in place when copying over the debug proxy assemblies so TIL.