Visual Studio 2010 “Publish” does not copy Razor view files

£可爱£侵袭症+ 提交于 2019-12-18 12:12:41

问题


When using the built-in Publish feature of Visual Studio 2010 with a web application that includes Razor views (.cshtml or .vbhtml), the publish service does not copy the Razor view files.

This occurs both on a local "File System" publish as well as a remote publish using Web Deploy, using the November 9 Release Candidate.

Are there any known workarounds?


回答1:


You need to set the build action to "Content" under properties.

Edit: You have to do this on each of the files that aren't being copied over.

Edit 2: I did some poking around, and found a forum posting over at msdn, sounds like you can edit the registry, or create a pkdef file.

http://social.msdn.microsoft.com/Forums/en/vsxprerelease/thread/c0212d15-96c4-455d-b7e1-d299c5ef384a




回答2:


(This answer is mostly if someone finds this through google etc)

As @Ted Ballou pointed out you need to change output type to Content. This can be quite cumbersome if you, like me, have 100+ files in different subfolders.

Especially since you can't update multiple files at once if there's a folder included in the selection.

Instead of changing through the GUI, open the project file and modify the settings directly.

In YourProject.csproj change items like:

<None Include="Views\Foo\Bar.cshtml />

to

<Content Include="Views\Foo\Bar.cshtml" />

I used the following Regular Expression to replace all files:

Search for: <None Include="(.+)\.cshtml" />

Replace with: <Content Include="$1.cshtml" />

Now Visual Studio should treat all your changed cshtml as Content on publish.



来源:https://stackoverflow.com/questions/4146806/visual-studio-2010-publish-does-not-copy-razor-view-files

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!