130
votes

When I try to compile my project from x86 debug mode in Visual Studio 2008. I am getting this error. When I looked at the property group of the project that complained, I see output path is set.

Here is the property group section for that .csproj file

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
  <DebugSymbols>true</DebugSymbols>
  <OutputPath>bin\x86\Debug\</OutputPath>
  <DefineConstants>DEBUG;TRACE</DefineConstants>
  <BaseAddress>285212672</BaseAddress>
  <FileAlignment>4096</FileAlignment>
  <DebugType>full</DebugType>
  <PlatformTarget>x86</PlatformTarget>
 <ErrorReport>prompt</ErrorReport>

Can any one shed the light on this?

NOTE: When I compiled this Debug and Any CPU it worked.

UPDATED: Error 1 The OutputPath property is not set for this project. Please check to make sure that you have specified a valid Configuration/Platform combination. Configuration='Debug' Platform='x86'

21
Ok and what configuration and platform do you use? Debug + x86 or something else?Ondrej Tucny
Yes VS configuration manager I choose debug + x86Amzath
@DmitryShkuropatsky updated error messageAmzath
It looks correct. Is there another project in the solution that may cause the error?Dmitry Shkuropatsky
@DmitryShkuropatsky you are right it was another project that had issue. But VS complained about the project that is being compiledAmzath

21 Answers

248
votes

I had exact same error after adding a new configuration via ConfigurationManager in Visual Studio.

It turned out when the 'Production' configuration was added for the whole solution (and each project) the OutputPath element was not added to the .csproj files.

To fix, I went to the Build tab in project properties, changed OutputPath from \bin\Production\ to \bin\Production (deleted trailing \) and saved changes. This forced creation of the OutputPath element in the .csproj file and the project has built successfully.

Sounds like a glitch to me.

29
votes

You can see this error in VS 2008 if you have a project in your solution that references an assembly that cannot be found. This could happen if the assembly comes from another project that is not part of your solution but should be. In this case simply adding the correct project to the solution will solve it.

Check the References section of each project in your solution. If any of them has a reference with an red x next to it, then it you have found your problem. That assembly reference cannot be found by the solution.

The error message is a bit confusing but I've seen this many times.

27
votes

If you are using WiX look at this (there is a bug) http://www.cnblogs.com/xixifusigao/archive/2012/03/20/2407651.html

Sometimes new build configurations get added to the .wixproj file further down the file, that is, separated from their sibling config definitions by other unrelated XML elements.

Simply edit the .wixproj file so that all the <PropertyGroup> sections that define your build configs are adjacent to one another. (To edit the .wixproj in VS2013 right click on project in Solution Explorer, Unload project, right-click again->Edit YourProject.wixproj. Reload after editing the file.)

17
votes

This happened to me because I had moved the following line close to the beginning of the .csproj file:

  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets"/>

It needs to be placed after the PropertyGroups that define your Configuration|Platform.

11
votes

The error shown in visual studio for the project (Let's say A) does not have issues. When I looked at the output window for the build line by line for each project, I saw that it was complaining about another project (B) that had been referred as assembly in project A. Project B added into the solution. But it had not been referred in the project A as project reference instead as assembly reference from different location. That location contains the assembly which compiled for Platform AnyCpu. Then I removed the assembly reference from the project A and added project B as a reference. It started compiling. Not sure though how this fix worked.

11
votes

had this problem as output from Azure DevOps after setting to build the .csproj instead of the .sln in the Build Pipeline.

The solution for me: Edit .csproj of the affected project, then copy your whole

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCpu' ">

Node, paste it, and then change the first line as followed:

    <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|any cpu' ">

The reason is, that in my case the error said

Please check to make sure that you have specified a valid combination of Configuration and Platform for this project.  Configuration='release'  Platform='any cpu'.  

Why Azure wants to use "any cpu" instead of the default "AnyCpu" is a mystery for me, but this hack works.

9
votes

I encountered the same error but the problem turned out to be because I had created a new configuration in my solution that didn't exist in referenced assemblies from another solution.

This can be resolved by opening the related solution and adding the new configuration to it as well.

This post gave me the idea to check the referenced assemblies after I'd already confirmed that all projects within my solution had the correct configuration:

http://gabrielmagana.com/2010/04/solution-to-the-outputpath-property-is-not-set-for-this-project/

5
votes

If you get this error only when you try to compile your project from commandline using MSBuild (like in my case) then the solution is to passing the outputpath manually to MSBuild with an argument like /p:OutputPath=MyFolder.

4
votes

I had the same error, so I looked on project settings and there in "Build" section is "Build output path" option. And value was empty. So I filled in "bin\" value a error disappeared. It solved my problem.

3
votes

I have:

  1. Right-click on project with issue -> Unload Project
  2. Right-click on project and choose Edit *.csproj
  3. Copy-paste the configuration from existing configuration which works with specific name and targeting platform (I had Release | x64):

    <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
      <OutputPath>bin\x64\Release\</OutputPath>
      <DefineConstants>TRACE</DefineConstants>
      <Optimize>true</Optimize>
      <DebugType>pdbonly</DebugType>
      <PlatformTarget>x64</PlatformTarget>
      <ErrorReport>prompt</ErrorReport>
      <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
      <Prefer32Bit>true</Prefer32Bit>
    </PropertyGroup>
    
  4. Right-click project -> Reload Project
  5. Rebuild project/solution
2
votes

Another crazy possibility: If you follow a simple source control arrangement of putting Branch\Main, Main, and Release next to each other and you somehow end up adding an existing project from Main instead of Branch\Main (assuming your working solution is Branch\Main), you may see this error.

The solution is simple: reference the right project!

2
votes

I encountered this problem when adding a project to a solution then referencing it from yet another project in the same solution-- got the yellow warning icon over the reference, notice that path was empty.

The solution was similar to what @Amzath suggested, my projects were being compiled with different Target Frameworks, eg. .NET 4.0 vs 4.5.

2
votes

In my case the built address of my app was set to another computer that was turned off so i turned it on and restart VS and problem solved.

2
votes

Another cause: you add a project reference from project A to project B in solution X. However, solution Y that already contains project A is now broken, until you also add project B to solution Y.

2
votes

I had the same problem after I have added new configurations and deleted the "debug" and "release" configs. In my case I was using a cmd file to run the build and publish process, but the same error was thrown. The solution for me: In the csproj file the following:

<Configuration Condition=" '$(Configuration)' == '' ">Debug< /Configuration>

was setting the Configuration to "Debug" if I did not specify an explicit one. After changing the node value from "debug" to my custom configuration, it all worked smoothly. Hope this will also help whoever is reading this :)

2
votes

I had the same problem, Just edit the .wixproj to have all of the <PropertyGroup Condition=" '$(Configuration)|$(Platform)' ... > elements to be side by side.

That solved my issue

1
votes

The WiX project I was using was hard-set in the configuration manager for x64 across the board. When making the Custom Action project for the solution, it defaulted everything to x86 within the .csproj file. So I unloaded the project, edited it by changing all x86 to x64, saved, reloaded, and was good to go after that.

I don't understand why I had to do this. The configuration manager was set to build as x64, but just wouldn't get set in the csproj file :(

0
votes

After trying all the other suggestions posted here, I discovered the solution for me was to remove the following section from the .csproj file:

  <ItemGroup>
    <Service Include="{808359B6-6B82-4DF5-91FF-3FCBEEBAD811}" />
  </ItemGroup>

Apparently this service from the original project (unavailable on local machine) was halting the entire build process, even though it wasn't essential for compilation.

0
votes

I got this problem after adding a new platform to my project. In my case .csproj file was under Perforce source control and was read-only. I checked it out but VS didn't catch the change until I restarted it.

0
votes

I have had similar issue on a Xamarin Project. It is maybe rare case but in case anyone else is having the issue. my project structure was like below

  • xamarin.Android project had a reference from xamarin.android.library project.
  • I created a plugin using some code from android.library project.
  • Now here is the problem. if you add project reference or nuget installation on xamarin.android library project. You will get this error. Developers assume that code was inside Android.Library project and i must reference the new plugin on this project. NO!
  • you must add a reference on Main Android project. because plugin->library->main project output isnt produced.
0
votes

Similar to Philip Atz, I had the following line at the top of my .csproj file.

<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.CSharp.targets" />

Moving it further down solved this problem for me.