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

狂风中的少年 提交于 2019-12-21 05:41:22

问题


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?


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/309255/how-do-i-add-an-msbuild-proj-file-to-my-solution

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!