2013-06-28 64 views
5

我和我的團隊正在將VS2012用於許多項目,並已與我們的QA和UAT小組開發了一個工作流程,涉及5個環境:本地,開發階段,測試,預生產和生產。我們發現自己必須爲每個項目和解決方案創建Local/Dev/Test/Preprod/Prod構建配置,並刪除調試和發佈配置。將默認構建配置添加到Visual Studio

有沒有什麼辦法可以讓VS在新項目中默認創建這些環境而不是調試/發佈配置?

編輯: 我一直沒有找到任何全球選項,因爲它似乎構建配置都在個別的項目文件夾。

我所做的一切就是找到我的一些最常見的項目正是如此修改的項目模板:

  • 修改的.csproj文件,並替換爲以下PropertyGroups:
    <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Local|AnyCPU' "> 
        <DebugSymbols>true</DebugSymbols> 
        <DebugType>full</DebugType> 
        <Optimize>false</Optimize> 
        <OutputPath>bin\</OutputPath> 
        <DefineConstants>DEBUG;TRACE</DefineConstants> 
        <ErrorReport>prompt</ErrorReport> 
        <WarningLevel>4</WarningLevel> 
    </PropertyGroup> 
    <-- SNIP --> 
    <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Prod|AnyCPU' "> 
        <DebugType>pdbonly</DebugType> 
        <Optimize>true</Optimize> 
        <OutputPath>bin\</OutputPath> 
        <DefineConstants>TRACE</DefineConstants> 
        <ErrorReport>prompt</ErrorReport> 
        <WarningLevel>4</WarningLevel> 
    </PropertyGroup>
  • 添加我的適當Web.Config中變換指令:
    <Content Include="Web.config" /> 
    <Content Include="Web.Local.config"> 
        <DependentUpon>Web.config</DependentUpon> 
    </Content> 
    <Content Include="Web.Dev.config"> 
        <DependentUpon>Web.config</DependentUpon> 
    </Content> 
    <Content Include="Web.Test.config"> 
        <DependentUpon>Web.config</DependentUpon> 
    </Content> 
    <Content Include="Web.Preprod.config"> 
        <DependentUpon>Web.config</DependentUpon> 
    </Content> 
    <Content Include="Web.Prod.config"> 
        <DependentUpon>Web.config</DependentUpon> 
    </Content>
  • 修改我的.vstemplate文件,並替換了Web.Debug和Web.Release配置條目這樣的:
    <ProjectItem ReplaceParameters="true" TargetFileName="Web.config">WebApiWeb.config</ProjectItem> 
    <ProjectItem ReplaceParameters="true" TargetFileName="Web.Local.config">Web.Local.config</ProjectItem> 
    <ProjectItem ReplaceParameters="true" TargetFileName="Web.Dev.config">Web.Dev.config</ProjectItem> 
    <ProjectItem ReplaceParameters="true" TargetFileName="Web.Test.config">Web.Test.config</ProjectItem> 
    <ProjectItem ReplaceParameters="true" TargetFileName="Web.Preprod.config">Web.Preprod.config</ProjectItem> 
    <ProjectItem ReplaceParameters="true" TargetFileName="Web.Prod.config">Web.Prod.config</ProjectItem>
  • 我將Web.Debug.config複製並重命名爲Web.Local.config,Web.Dev.config和Web.Test.config,並將Web.Release.config重命名爲Web.Preprod.config和Web.Prod.config。

當我創建新項目時,我所需的所有環境都在那裏,並且調試不見了!然而,Release仍然存在,包括我刪除的web.Release.Config文件。任何想法這個外部的配置文件/構建配置可能來自哪裏?

回答

2

是的,創建一個custom project template。如果這還不夠,你甚至可以創建一個custom project type,但是這有點多。

+0

我已經導出了項目模板,這似乎很適合我的團隊發佈。但是,導入後仍然具有發佈文件/生成配置。有什麼建議麼? – greven

相關問題