.NET Transforms是否可以在csproj文件中更改PropertyGroup?(.NET Transforms is it possible to change PropertyGroup

编程入门 行业动态 更新时间:2024-10-28 12:23:04
.NET Transforms是否可以在csproj文件中更改PropertyGroup?(.NET Transforms is it possible to change PropertyGroup in csproj files?)

这种方式是一个愚蠢的问题。

我有一个包含许多配置的Web应用程序。 为简单起见,我们假设Qa和Local。

在我的每个项目中,每个配置都有一个PropertyGroup,用于在选择w配置时定义设置。

<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Qa|AnyCPU'"> <DeployIisAppPath>Default Web Site/</DeployIisAppPath> <DebugType>full</DebugType> <Optimize>false</Optimize> <OutputPath>bin\</OutputPath> <DefineConstants>TRACE</DefineConstants> <PlatformTarget>AnyCPU</PlatformTarget> <ErrorReport>prompt</ErrorReport> <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> <IncludeIisSettings>false</IncludeIisSettings> <DebugSymbols>true</DebugSymbols>

<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Local|AnyCPU'"> <DebugType>full</DebugType> <DebugSymbols>true</DebugSymbols> <OutputPath>bin\</OutputPath> <DefineConstants>DEBUG;TRACE</DefineConstants> <PlatformTarget>AnyCPU</PlatformTarget> <ErrorReport>prompt</ErrorReport> <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>

所以基本上Qa配置为尽可能优化,禁用调试,TRACE。 这对我何时部署有意义。 当我需要调试Qa时,问题出现了。 我将配置更改为Qa并将我的web.config更改为指向Qa配置。 这样,VS使用用于连接Qa的连接字符串为Qa构建bin路径。 这样做的副作用是它禁用了我所有项目的调试,我必须暂时将它们全部重新打开以获得我需要的断点。 那糟透了,我想要改变它。

是否可以在所有这些项目配置上启用Debug,然后使用某种工具在部署时将Debug撤消? 我的第一个想法是添加一个转换来修改它,但转换不能改变csproj文件吗? 还有其他工具可以做到这一点吗?

This way be a silly question.

I've got a web app with many configurations. For simplicity let's say Qa and Local.

In each of my projects there's a PropertyGroup for each of the configurations to define settings when w configuration is selected.

<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Qa|AnyCPU'"> <DeployIisAppPath>Default Web Site/</DeployIisAppPath> <DebugType>full</DebugType> <Optimize>false</Optimize> <OutputPath>bin\</OutputPath> <DefineConstants>TRACE</DefineConstants> <PlatformTarget>AnyCPU</PlatformTarget> <ErrorReport>prompt</ErrorReport> <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> <IncludeIisSettings>false</IncludeIisSettings> <DebugSymbols>true</DebugSymbols>

<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Local|AnyCPU'"> <DebugType>full</DebugType> <DebugSymbols>true</DebugSymbols> <OutputPath>bin\</OutputPath> <DefineConstants>DEBUG;TRACE</DefineConstants> <PlatformTarget>AnyCPU</PlatformTarget> <ErrorReport>prompt</ErrorReport> <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>

So basically Qa is configured to be as optimized as possible, disabling debugging, TRACE. Which makes sense for when I deploy. The problem comes when we I need to debug Qa. I change the configuration to Qa and change my web.config to point to the Qa configuration. This way VS builds bin path for Qa with the connections strings used to connect to Qa. The side effect of this is it disables debug on All of my projects and I have to turn them all back on temporarily to get breakpoints into what I need. That sucks, and I want ot change it.

Is it possible to just leave Debug enabled on all these projects configs then have some kind of tool that reverses Debug out when it's time to deploy? My first thought was adding a transform to modify this but transforms can't change csproj file right? Is there some other tool out there that can do this?

最满意答案

项目配置已经是确定何时使用哪些设置的好工具。 项目配置名称不必与目标环境成1对1关系 - 您可以拥有更多(或更少)。

因此,不是在一个配置设置中来回更改“QA”的调试设置,而是可以准备以下配置:

本地 QA调试 质量保证优化

..或者你需要多种不同的配置。

默认情况下,可以使用“QA优化”配置将CI工具集设置为部署到QA环境。 如果遇到难以跟踪的问题并需要远程调试,则可以使用“QA with debugging”配置来构建和部署。

The project configuration already is a good tool to determine when to use which settings. Project configuration names do not have to be in 1-to-1 relation to target environments - you can have more (or less).

So instead of changing debugging settings for "QA" in one configuration settings back and forth, you could have prepared configurations like:

local QA debugging QA optimized

.. or however many different configurations you need.

By default your CI toolset could be set up to deploy to QA environment using the configuration "QA optimized". If you run into a hard-to-track problem and need to debug it remotely, you can build and deploy instead using the "QA with debugging" configuration.

更多推荐

Qa,配置,Debug,projects,电脑培训,计算机培训,IT培训"/> <meta name="descript

本文发布于:2023-07-16 02:02:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1122194.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文件   csproj   Transforms   NET   change

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!