Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

asp.net core 2.0 has Microsoft.VisualStudio.Web.CodeGeneration files in output folder

I've created a new asp.net core 2.0 mvc web app using Visual Studio 2017.

It has a reference to NuGet package "Microsoft.VisualStudio.Web.CodeGeneration.Design" (2.0.0) which, it appears is required if I want to be able to scaffold views/controllers. (A feature which I require)

When I publish my web app, I wouldn't expect to see what (appears to be) a development dependency being published to my output folder... and yet, I have a bunch of assemblies such as

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

etc.

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

like image 214
Nathan Avatar asked Sep 15 '17 10:09

Nathan


1 Answers

Try editing the csproj file to replace the PackageReference elements for those packages with DotNetCliToolReference elements, e.g.

<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, those packages should still be available as tools but will not be included with the packaged website.

See dotnet core PackageReference vs DotNetCliToolReference

like image 147
Matt Varblow Avatar answered Sep 28 '22 09:09

Matt Varblow