Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"OutputPath property is not set" error occurs only when calling MSBuild in CCNET

I've made an MSBuild project that simply does an msbuild task with our solution file as parameter. I've defined a BeforeBuild target where I set some properties, and a Build target that executes the msbuild task.

I've confirmed that no errors occured when building the msbuild script in the command line console. However, when I use it in the msbuild task in my CCNET project, I keep getting the following error:

C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets (483,9): error: The OutputPath property is not set for project 'MyProject.msbuild'. Please check to make sure that you have specified a valid combination of Configuration and Platform for this project. Configuration='Debug' Platform='AnyCPU'. You may be seeing this message because you are trying to build a project without a solution file, and have specified a non-default Configuration or Platform that doesn't exist for this project.

I checked the build log and it seems that the error occurs during _CheckForInvalidConfigurationAndPlatform. It wasn't even able to continue to my Build task! Since the script is only intended to build the solution under Debug/Release and AnyCPU as platform, I tried to add the following lines to my msbuild project:

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

I could still build the project without errors in the command line, but CCNET is returning the same error mentioned above.

I don't understand why CCNET keeps getting the error, and I don't know what else to try.

Please help.

like image 362
LostInCCNET Avatar asked Dec 12 '22 21:12

LostInCCNET


1 Answers

I found I had a similar situation (but using TeamCity as my CI environment). In my particular case, the project was a Command Line application. To solve it, I had to manually edit my project file.

Find these lines:

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

Change the second line to:

<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>

The find the other platform-specific lines in the project file and change them. Example:

  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">

becomes:

  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">

My suspicion is our build servers are 64-bit and the Console Application project type in Studio won't let you make the project fit an AnyCPU platform...

After these changes, TeamCity had no problem with my build script.

like image 124
David Montgomery Avatar answered May 10 '23 19:05

David Montgomery