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

前端 未结 2 444
一整个雨季
一整个雨季 2020-12-30 01:43

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 cop

相关标签:
2条回答
  • 2020-12-30 02:33

    (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.

    0 讨论(0)
  • 2020-12-30 02:39

    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

    0 讨论(0)
提交回复
热议问题