2014-10-04 37 views
0

在Visual Studio 2012中,您可以在不同的自定義Web服務器基於關構建配置

Web項目的屬性設置自定義Web服務器 - >網絡 - >服務器 - >使用自定義Web服務器

UI不允許這樣做,但可以根據項目文件中的構建配置(調試,發佈等)指定不同的服務器嗎?

enter image description here

+0

號它不可能在Visual Studio 2012,並沒有在2013年 – 2014-10-04 03:18:22

回答

1

看來,有沒有辦法做到這一點。我想讓Debug和Release(和其他配置)構建分開,因爲我們在兩種配置中都做了不同的事情(例如,縮小資源等)。開發人員希望他們自己的配置跳過他們不關心的某些項目,並且輸出有所不同。

我最終使用web.config轉換將Web服務器指向包含給定配置的包的文件夾。我們必須通過手動修改的csproj文件中像這樣來實現這一目標:

<UsingTask TaskName="TransformXml" AssemblyFile="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v11.0\Web\Microsoft.Web.Publishing.Tasks.dll" /> 

<!--Generate transformed web.config in the intermediate directory--> 
<TransformXml Source="Web.config" Destination="$(IntermediateOutputPath)$(TargetFileName).config" Transform="Web.$(Configuration).config" /> 


<!--Force build process to use the transformed configuration file from now on.--> 
<ItemGroup> 
    <AppConfigWithTargetPath Include="$(IntermediateOutputPath)$(TargetFileName).config"> 
    <TargetPath>Web.config</TargetPath> 
    </AppConfigWithTargetPath> 
</ItemGroup>