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

Viewed 1483

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!

3 Answers

I'm referencing the package only in Debug builds:

<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="5.0.2" Condition="'$(Configuration)' == 'Debug'"  />

That way, it won't appear in a release build. The same goes for the Razor runtime compilation package Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation.

Related