Domanda

I'm trying to write a macro/anything else to iterate though all projects and remove all other build configuration other that Active Solution Configuration - Debug and Active Solution Platform - x86. Also after editing the configuration for all projects, I want to set pre-build and post-build events to all projects. I have no clue where to start. Please help. I have like 44 projects in solution and its really hard and time consuming to set all these manually.

Pre Build event:

rd /s /q "$(ProjectDir)bin"

Post Build event:

copy "$(TargetPath)" "$(SolutionDir)TOTALOUTPUT\" /y
È stato utile?

Soluzione

I could not understand your point clearly but let me try to help...

You can create a new configuration by clickint Build->Configuration Manager->New (top left, there is active solution configuration, click on it you will see New option) Name it and check the projects you wanna compile

Then simply go your solution, select the projects with Ctrl and then leftclick->properties VS allows you to change the properties of multiple projects, so you can easily writes post builds and pre builds events like that, it will work for all projects you selected...

Altri suggerimenti

You can choose to put this in a macro, or not, however I would actually recommend directly going to the .csproj and .sln files. In the .csproj files they have a series of property groups that specify the build configuration like so:

  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
    <PlatformTarget>x86</PlatformTarget>
    <DebugSymbols>true</DebugSymbols>
    <DebugType>full</DebugType>
    <Optimize>false</Optimize>
    <OutputPath>bin\Debug\</OutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>

If you create a simple script/program/etc that traverses all the .csproj files in question, and read the .csproj xml file. While going through it, you can simply ensure that only the 2 PropertyGroups defining configurations show up. These two configurations will be your debug/release configs. Further, in that same script you can add your pre/post build events, they are simply a different type of property group, such as so:

  <PropertyGroup>
    <PostBuildEvent>xcopy $(TargetName).* "%25SEARCH1%25"\bin\ /i /y</PostBuildEvent>
  </PropertyGroup>

Note: It is likely better to do this as a script when Visual Studio is closed rather than as a macro, but I see no reason why simply wrapping this into a macro wouldn't work either.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top