简体   繁体   中英

Changing output directory in VS2010 project doesn't work

I have combined several projects into one solution. I created empty solution and added these projects and here is a blue print of how it looks like:

Root:
 Project1 - directory
 Project2 - directory
 Debug - directory
 Main.sln - file

Now I want to direct the executable and dll from both projects to \\debug folder shown up of the solution file. I go into project properites >> Configuration Properities >> General >> 'Output Directory' and change the output directory to $(SolutionDir)$(Configuration)\\ which is default for a new project.

The problem is that it has no effect on where the output file is created, it is still created in the old destination. The old path for `Output Directory' was .\\Debug\\ not that it matters.

Could this be because the SolutionDir & Configuration may not be defined? Where can I see their definition or values? I also want to create a new configuration which would be 'Release with Debug' how can I create that using environment variable? Thanks!

My project is MFC/Visual C++.

Add-on: Where are these identifiers like SolutionDir defined in the scrip? I look up for in .vcxproj file but there is mention of it. I create a new dummy VS2010 project just to look at it's .vcxproj file but these project settings identified are not defined in any place that I can see!

This is most likely caused by specific settings overriding global settings, namely Linker's "output" setting. This happens often as a result of conversion from earlier Visual Studio.

What you need is to go through every setting, paying attention to those whose values are written in bold, and reset to default (select it from dropdown) every setting with 'debug' or 'release', and others as necessary.

There could also be specific settings on files. I usually resolve this by opening project in notepad and removing any excessive settings. Just be careful. Using multiline replace in Notepad++ or any other capable editor helps.

I had a similar problem with the Intermediate Directory setting in one of my VS2010 projects. No matter what I set it to, it would always use the default value of $(SolutionDir)$Configuration. Oddly, other projects in the same solution with the same settings worked just fine.

After playing around, I stumbled upon a solution.

  1. Click on the setting in the propery page dialog.
  2. Click on the down arrow button in the right-hand side of the edit box.
  3. Select "inherit from parent or project defaults".
  4. Click "Apply".
  5. Click on the setting and change it to your desired value.

I don't know why this works, but it does. It seems like the macros were not being properly evaluated for whatever reason. Then, after you apply the inherited values, it seems to reset itself and start evaluating the macros properly.

I think I had a similar problem.

What I ended up doing was editing the vcxproj file directly. Find this section and edit it like this for each of your configurations:

  <PropertyGroup>
    <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
    <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
  </PropertyGroup>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM