简体   繁体   English

Visual Studio发布使用调试模式而不是发布

[英]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/0sitesroot/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: 需要做的是:

  1. 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)" 
  2. 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.

相关问题 Visual Studio:在“调试”模式下生成,但文件仍在“发布”文件夹中生成 - Visual Studio: Building in Debug mode but the files still built in Release folder Visual Studio - 调试与发布 - Visual Studio - Debug vs Release Visual Studio 2010 认为它处于调试模式(但它设置为发布模式) - Visual Studio 2010 Thinks it's in Debug Mode (but it's set to Release mode) 如何在发布模式下处于活动状态时以调试模式关闭Visual Studio中的DocFX? - How to switch off DocFX in visual studio in debug mode while active in release mode? 代码可以在调试中运行并从Visual Studio运行,但是发布模式会出现错误 - Code works in debug and running from visual studio however release mode gives error UWP 应用程序在 Visual Studio 调试模式下工作,但发布版本无法运行,缺少 DLL (C#) - UWP App works in Visual Studio debug mode, but the release build won't run, missing DLL (C#) Visual Studio 2015:我无法在发布模式下调试和使用断点 - Visual Studio 2015: I can't debug and use breakpoints in Release mode Microsoft Visual Studio:如何在不离开调试模式的情况下进行一键式发布构建? - Microsoft Visual Studio: how to make one-click release builds without leaving debug mode? 以发布模式发布应用程序,并自动将debug设置为false - publish application in release mode and automatically set debug to false Visual Studio 2015调试和发布无法正常工作 - Visual Studio 2015 Debug and Release not working
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM