Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I add an MSBuild .proj file to my solution?

Tags:

msbuild

Does anyone know how to add a an MSBuild .proj file to my solution?

I was just given existing code from a vendor with a solution that references an MSBuild .proj file as one of its projects. When I open the solution, the project shows as (unavailable). It appears that I need to install some sort of project template to get this project to open correctly. I installed the Codeplex MSBuild Template, but this doesn't appear to be it.

Any ideas?

like image 610
Peter Walke Avatar asked Sep 05 '25 16:09

Peter Walke


2 Answers

If you don't need IDE support, it's possible to do this using MSBuild solution extension targets.

Create a file named "before.SolutionName.sln.targets" with the following code:

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <ItemGroup>
    <ProjectReference Include="CustomProject\CustomProject.proj">
      <AdditionalProperties>Configuration=$(Configuration); Platform=AnyCPU</AdditionalProperties>
      <Configuration>$(Configuration)</Configuration>
      <Platform>AnyCPU</Platform>
    </ProjectReference>
  </ItemGroup>
</Project>

When your solution is built at command line by MSBuild (ie/ build server) the custom MSBuild project will be pulled into the temporary in-memory project file that MSBuild converts the solution into.

like image 94
ShadowChaser Avatar answered Sep 07 '25 16:09

ShadowChaser


I actually got it to work! I re-started Visual Studio and still saw that the projects were unavailable after installing the MSBuild Template mentioned above. I had to manually reload the projects. That fixed the issue.

like image 25
Peter Walke Avatar answered Sep 07 '25 18:09

Peter Walke