向Visual Studio添加默认构建配置

5
我的团队和我正在使用VS2012进行多个项目,并与我们的QA和UAT小组开发了一种工作流,其中涉及5个环境:本地、开发暂存、测试、预生产和生产。我们发现自己不得不为每个项目和解决方案创建Local/Dev/Test/Preprod/Prod构建配置,并删除调试和发布配置。
有没有办法让VS在新项目中默认创建这些环境,而不是调试/发布配置?
编辑: 我未能找到任何全局选项,因为构建配置都在各个项目文件夹中。
我所做的是找到一些最常见的项目,并修改了项目模板。
  • Modify the .csproj file and replace PropertyGroups with the following:
    <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>
  • Add my appropriate Web.Config transform directives:
    <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>
  • Modified my .vstemplate file and replaced the Web.Debug and Web.Release config entries as such:
    <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>
  • I copied and renamed Web.Debug.config to Web.Local.config, Web.Dev.config, and Web.Test.config and Web.Release.config to Web.Preprod.config and Web.Prod.config.

当我创建新项目时,我想要的所有环境都在那里,但调试却不见了!然而,发布仍然存在,包括我删除的web.Release.Config文件。你有任何想法这个多余的配置文件/构建配置可能来自哪里吗?

1个回答

2

我已经导出了项目模板,对于团队的分发来说似乎效果不错。然而,在导入时仍然保留了发布文件/构建配置。有什么建议吗? - greven

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接