[英]Visual Studio publish uses debug mode instead of release
The setup is this: 设置是这样的:
.NET 4.5
Visual Studio 2012
Azure 2.0
one WebRole which hosts 2 sites:
one MVC4
one WCF project
When I published the site to the cloud, it looked like it was working in debug mode. 当我将站点发布到云中时,它似乎正在调试模式下工作。 I published it by right-clicking the cloud project, clicking publish and selecting the config version and the "release" build version when it prompted.
我通过右键单击云项目,单击“发布”并在出现提示时选择配置版本和“发布”构建版本来发布它。
To check what happened, I opened up the .cspkg
file by changing the extension to .zip
, and checked the .cssx
file in it (also changed the extension to .zip
). 为了检查发生了什么,我通过将扩展名更改为
.zip
来打开.cspkg
文件,并检查其中的.cssx
文件(也将扩展名更改为.zip
)。 This allowed me to see the sitesroot/0
and sitesroot/1
folders which had my website and service. 这使我能够看到具有我的网站和服务的
sitesroot/0
和sitesroot/1
文件夹。 These contained source code, even the .csproj
files. 这些包含源代码,甚至包括
.csproj
文件。 To compare, I checked another solution on the cloud, which just had the bin
folder and the only non-compiled code were the views and .js
scripts and stylesheets. 作为比较,我在云上检查了另一个解决方案,该解决方案只有
bin
文件夹,唯一的未编译代码是视图, .js
脚本和样式表。
I've made sure that the compilation element in the individual projects' configs looked like this: 我确保各个项目的配置中的编译元素看起来像这样:
<compilation debug="false">
Anyway, whatever I do it looks like it builds a package in debug mode. 无论如何,无论我做什么,它看起来都像在调试模式下构建了一个程序包。 I'm completely in a loss, and I don't know what to look at anymore, since everything looks fine.
我完全不知所措,而且我不知道该看什么,因为一切看起来都很好。
This question shows a related problem: VS publish to azure uses debug instead of release 这个问题显示了一个相关的问题: VS发布到天蓝色使用调试而不是发布
But they're using TFS to automate the build and publish process, while I'm doing it manually. 但是他们正在使用TFS自动化构建和发布过程,而我正在手动进行。
Any tips or pointers would come in handy. 任何提示或指示将派上用场。 Or at least a list of things to check and compare with other projects.
或至少列出要检查的项目并与其他项目进行比较。
After a bit(lot) more digging, I've found the reason. 经过更多的挖掘,我找到了原因。 It's the multiple sites on one web role that cause issues.
一个网站角色上的多个站点会引起问题。 Since the site code just gets copied into the
sitesroot
folder. 由于站点代码只是被复制到
sitesroot
文件夹中。
I've managed to solve the issue following the article here: 我已设法解决以下文章中的问题:
http://michaelcollier.wordpress.com/2013/01/14/multiple-sites-in-a-web-role/ http://michaelcollier.wordpress.com/2013/01/14/multiple-sites-in-a-web-role/
What needs to be done is: 需要做的是:
setup prebuild and postbuild events on each of the sites to take care of copying the built dlls into a custom build folder 在每个站点上设置prebuild和postbuild事件,以将生成的dll复制到自定义生成文件夹中
Pre (clears the custom build folder): rmdir "$(ProjectDir)..\\YOUR-AZURE-PROJECT\\Sites\\$(ProjectName)" /S /Q Post (copies dlls to the custom build folder): %WinDir%\\Microsoft.NET\\Framework\\v4.0.30319\\MSBuild.exe "$(ProjectPath)" /T:PipelinePreDeployCopyAllFilesToOneFolder /P:Configuration=$(ConfigurationName);PreBuildEvent="";PostBuildEvent="";PackageAsSingleFile=false;_PackageTempDir="$(ProjectDir)..\\YOUR-AZURE-PROJECT\\Sites\\$(ProjectName)"
change the sites elements in ServiceDefinition.csdef
to point to the custom build folder 更改
ServiceDefinition.csdef
的sites元素以指向自定义生成文件夹
<Sites> <Site name="WebSite" physicalDirectory="..\\..\\Sites\\WebSite\\"> <Bindings> <Binding name="Endpoint1" endpointName="Endpoint2" /> </Bindings> </Site> </Sites>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.