In asp.net core 2.0 there are Microsoft.VisualStudio.Web.CodeGeneration files in the output folder

I created a new asp.net core 2.0 mvc web application using Visual Studio 2017.

It has a link to the NuGet package "Microsoft.VisualStudio.Web.CodeGeneration.Design" (2.0.0), which is apparently required if I want to be able to view / control the scaffold. (The function I need)

When I publish my web application, I would not expect to see what (it seems) a development dependency is published in my output folder ... and yet I have a bunch of assemblies like

Microsoft.VisualStudio.Web.CodeGeneration.dll, Microsoft.VisualStudio.Web.CodeGeneration.Templating.dll, Microsoft.VisualStudio.Web.CodeGeneration.Utils.dll

and etc.

Am I doing something wrong ?: How can I reduce all these additional dlls? There is one (Microsoft.CodeAnalysis.Workspaces.dll), which is ~ 2Mb!

+6
source share
2 answers

Try setting PrivateAssets for everyone in the csproj file, this worked for me. There is a really good thread describing this problem.

<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.0.2">
  <PrivateAssets>all</PrivateAssets>
</PackageReference>
0
source

Try editing the csproj file to replace the PackageReference elements for these packages with DotNetCliToolReference elements, for example.

<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.0.3" PrivateAssets="All" />

becomes

<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.0.3" />

With this change, these packages should still be available as tools, but will not be included in the batch website.

See dotnet core PackageReference vs DotNetCliToolReference

0
source

All Articles