visual-studio - 将默认构建配置添加到 Visual Studio

标签 visual-studio visual-studio-2012 buildconfiguration

我和我的团队正在将 VS2012 用于许多项目,并与我们的 QA 和 UAT 小组一起开发了一个工作流程,其中涉及 5 个环境:本地、开发阶段、测试、预生产和生产。我们发现自己必须为每个项目和解决方案创建 Local/Dev/Test/Preprod/Prod 构建配置,并删除调试和发布配置。

有没有办法让 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 配置条目,如下所示:
    WebApiWeb.config
    Web.Local.config
    Web.Dev.config
    Web.Test.config
    Web.Preprod.config
    Web.Prod.config
  • 我将 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 文件。知道这个无关的配置文件/构建配置可能来自哪里吗?

    最佳答案

    是的,创建一个 custom project template .如果这还不够,您甚至可以创建一个 custom project type ,然而,这有点复杂。

    关于visual-studio - 将默认构建配置添加到 Visual Studio,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17371404/

    相关文章:

    teamcity - 在 teamcity 中移动构建配置的问题

    c++ - Visual Studio 中解决方案范围的构建配置?

    asp.net - 调试时无法对 ASP.NET 代码进行更改

    c# - 如何从 Visual Studio 2012 中的 resharper 测试 session 窗口导航到功能文件?

    c# - Visual Studio "Could not copy".... 在构建期间

    c++ - 我可以简化这种安装和导出基于 CMake 的项目的方法吗?

    c# - Visual Studio 2017 工作室显示错误 'This application is in break mode' 并引发未处理的异常

    visual-studio - 从 VS 项目中删除资源图像的正确方法是什么?

    visual-studio - 我应该如何在Visual Studio中使用调试/ Release模式?

    C++ 禁用忙碌/等待光标