Is there a way to "override" the .csproj parameter?

There are many projects in my solution.

I would like each of them to have an overridden setting. I could just edit them all. But it is tiring and error prone for the developers who follow me.

So, I hope there is a way to combine the custom .proj file into a .csproj before the build really starts.

The setting I want to change is the output setting (for Debug configuration). I want to set it to $ (SolutionDir) \ bin \ Debug.

Am I a thinking thinker? or is there a way to do this?

+4
source share
2 answers

You can create your own .targets file that sets the properties that you want to distribute for all your projects.

In your regular .targets file, set the property:

<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'"> <OutputPath>$(SolutionDir)\bin\Debug</OutputPath> </PropertyGroup> 

You still have to include this target file in each .csproj file, as well as delete the previously set OutputPath property (otherwise, it will override the one installed in your .targets file).

 <Import Project="<PathToYourTargetsFile>"/> 

While this is still related to editing each .csproj file, it’s a little more convenient than setting this property directly in each file, especially if you think there may be more settings that you want each project to have in common In the future, in any added projects, developers had to remember this .targets file.

+6
source

Set the output parameter from the msbuild command line:

/ p: OutputPath = "$ (SolutionDir) \ Bin \ Debug"

OutputPath - indicates the path to the output directory relative to the project directory, for example, "bin \ Debug".

Another option is to place the configuration override inside the csproj file. As shown below. Not sure if this is what you want to do.

 <Config Name = "Release" AllowunsafeBlocks = "false" BaseAddress = "285212672" CheckForOverflowUnderflow = "false" ConfigurationoverrideFile = "debug. web. config" DefineConstants = "TRACE" DocumentationFile = " DebugSymbols = "false" FileAlignrnent = "4096" IncrementalBuild = "false" Optimize = "true" OutputPath = "bin\" RegisterForcomlnterop = "false" RemovelntegerChecks = "false" TreatWarningsAsErrors = "false" WarningLevel = "4" /> 
+3
source

All Articles