ASP.NET Core的预编译视图在发布时 [英] ASP.NET Core precompiled views on publish

查看:110
本文介绍了ASP.NET Core的预编译视图在发布时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我以前使用.NET Core 2.0预览版1和Visual Studio 2017 15.3预览版创建了一个ASP.NET Core项目.只是项目模板中的默认内容,尚无自定义代码.然后,我使用发布"命令并将所有内容复制到目录bin \ Release \ PublishOutput.一切都很好. 5 MB,可以部署到生产Web服务器上并且可以正常工作.

I've previously created an ASP.NET Core project with .NET Core 2.0 preview 1 and Visual Studio 2017 15.3 preview. Just the default stuff from the project template, no custom code yet. Then I used the Publish command and have everything copied to the directory bin\Release\PublishOutput. All nice and good. 5 MB, can be deployed to the production web server and it works.

现在我已经用VS Code尝试了同样的事情,只是一无所获.我用dotnet new mvc创建了项目,并用code .在VS Code中将其打开.关闭几次并打开.cs文件后,我想我现在已经跳过了VS Code附带的所有障碍.我可以在本地运行该应用程序.

Now I've tried the same thing with VS Code and just won't get anywhere. I created the project with dotnet new mvc and opened it in VS Code with code .. After closing and opening it a few times and editing .cs files, I think I've now jumped over all the hurdles that VS Code comes with. I can run the application locally.

但是发布并不能产生理想的结果.我手动运行dotnet publish -c Release,因为VS Code在这里似乎什么都没有提供.我在bin \ Release \ netcoreapp2.0中获得了大量文件,还有一个名为publish的子目录.两者都有MySite.dll和MySite.pdb的副本,但没有预编译的视图DLL.另外,发布目录具有54 MB的运行时DLL,这对于Visual Studio给我的东西不是必需的.

But the publishing doesn't quite produce the desired result. I run dotnet publish -c Release manually because VS Code doesn't seem to offer anything here. I get tons of files in bin\Release\netcoreapp2.0, along with a subdirectory called publish. Both have a copy of MySite.dll and MySite.pdb, but no precompiled views DLL. Also, the publish directory has 54 MB of runtime DLLs that weren't required for what Visual Studio gave me.

使用VS Code发布ASP.NET Core MVC应用程序的预期方法是什么?一切都是最新版本,今天已下载并安装.

What is the intended method to publish an ASP.NET Core MVC application with VS Code? Everything is the latest version, downloaded and installed today.

我是否需要完整的Visual Studio中的组件才能获得具有所有广告功能的完整发布体验?

Do I need components from the full Visual Studio to get the complete publishing experience, with all the advertised features?

推荐答案

为便于记录,我最近在ASP.NET Core 2.0预览版2中发现此问题已得到解决.使用dotnet new mvc创建的项目在csproj文件中设置了MvcRazorCompileOnPublish属性,并且dotnet publish的功能与现在通过Visual Studio 2017(15.3)发布的功能相同.

For the record, I have recently discovered in ASP.NET Core 2.0 preview 2 that this has been resolved. A project created with dotnet new mvc has the MvcRazorCompileOnPublish property set in the csproj file, and dotnet publish does the same as publishing through Visual Studio 2017 (15.3) now.

这篇关于ASP.NET Core的预编译视图在发布时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆