0
votes

I'm trying to get other projects in my solution to build, with a specific configuration, when an installer project is built. In Installer.csproj I have the following:

<Target Name="BuildProjects" AfterTargets="Build">
  <MSBuild Projects="$(SolutionPath)" Targets="Applications\ProjectName"
     Properties='Configuration="Debug 2019";Platform="Any CPU";OutputPath=$(TargetDir)ProjectName/'>
  </MSBuild>
</Target>

This fails with a message in Output:

C:\Users\path\to\Solution.sln.metaproj : error MSB4057: The target "Applications\ProjectName" does not exist in the project.

However, if I run the following command in the developer command prompt, it works:

msbuild C:\Users\path\to\Solution.sln -t:Applications\ProjectName -p:Configuration="Debug 2019";Platform="Any CPU";OutputPath=C:\Users\path\to\Installer\bin\Debug 2019\ProjectName\

As far as I've been able to determine, these are saying the same thing. As a temporary solution I can run the command in an Exec task, but I'd like to take advantage of the MSBuild task.

1

1 Answers

0
votes

OK, this was just my lack of understanding/reading the MSBuild task documentation. As far as I can tell, the Targets property doesn't correspond to the -t flag in msbuild.exe. I had more success with something like:

<MSBuild Projects="$(SolutionPath)Applications\ProjectName.csproj"
     Properties="Configuration='Debug 2019';Platform='Any CPU';OutputPath=$(TargetDir)ProjectName/">
</MSBuild>