I'm not sure how I can get the MSBuild script to use the outputpath, outputdirectory values from the CSproj files. I've seen examples where I set the outputpath in the MSscript but that dumps the all the output in one big folder. I want the individual projects to have their own output paths and MSbuild to build the solution in such a way that the output for the projects and created in the corresponding output directories. Thanks.
我不知道如何让MSBuild脚本使用CSproj文件中的outputpath,outputdirectory值。我已经看到了一些示例,我在MSscript中设置了outputpath,但是将所有输出转储到一个大文件夹中。我希望各个项目有自己的输出路径和MSbuild来构建解决方案,使得项目的输出和在相应的输出目录中创建。谢谢。
2 个解决方案
#1
There is not an easy way. One option is to extend MSBuild and have it copy the output from each project to a common folder.
没有一个简单的方法。一种选择是扩展MSBuild并将其从每个项目的输出复制到公共文件夹。
If you look at the Microsoft.Common.Targets file in the c:\Windows\Microsoft.Net\Framework\v4.*\ you can see how it does load a custom targets file at both the beginning and end of that folder. If you add a Custom.After.Microsoft.Common.Targets to the C:\Program Files (x86)\MSBuild\v4\ folder you can have it load a file say $(SolutionDir)\Solution.targets. This will allow you to extend each solution differently and you can add any custom actions you want inside every solution that applies to every project. I use this and it works great.
如果您查看c:\ Windows \ Microsoft.Net \ Framework \ v4。* \中的Microsoft.Common.Targets文件,您可以看到它如何在该文件夹的开头和结尾加载自定义目标文件。如果您将Custom.After.Microsoft.Common.Targets添加到C:\ Program Files(x86)\ MSBuild \ v4 \文件夹,您可以让它加载一个文件说$(SolutionDir)\ Solution.targets。这将允许您以不同方式扩展每个解决方案,并且您可以在适用于每个项目的每个解决方案中添加所需的任何自定义操作。我使用它,效果很好。
#2
Thanks for your answers guys. I found a way to run the solution without giving a specific output folder. I had to fix the output folder path to /bin in the csprojs and then running MSbuild with the solution was able to pick up those paths from the csprojs and build the output into those folders.
谢谢你的答案。我找到了一种方法来运行解决方案而不提供特定的输出文件夹。我必须将输出文件夹路径修复到csprojs中的/ bin,然后运行MSbuild,解决方案能够从csprojs中获取这些路径并将输出构建到这些文件夹中。
#1
There is not an easy way. One option is to extend MSBuild and have it copy the output from each project to a common folder.
没有一个简单的方法。一种选择是扩展MSBuild并将其从每个项目的输出复制到公共文件夹。
If you look at the Microsoft.Common.Targets file in the c:\Windows\Microsoft.Net\Framework\v4.*\ you can see how it does load a custom targets file at both the beginning and end of that folder. If you add a Custom.After.Microsoft.Common.Targets to the C:\Program Files (x86)\MSBuild\v4\ folder you can have it load a file say $(SolutionDir)\Solution.targets. This will allow you to extend each solution differently and you can add any custom actions you want inside every solution that applies to every project. I use this and it works great.
如果您查看c:\ Windows \ Microsoft.Net \ Framework \ v4。* \中的Microsoft.Common.Targets文件,您可以看到它如何在该文件夹的开头和结尾加载自定义目标文件。如果您将Custom.After.Microsoft.Common.Targets添加到C:\ Program Files(x86)\ MSBuild \ v4 \文件夹,您可以让它加载一个文件说$(SolutionDir)\ Solution.targets。这将允许您以不同方式扩展每个解决方案,并且您可以在适用于每个项目的每个解决方案中添加所需的任何自定义操作。我使用它,效果很好。
#2
Thanks for your answers guys. I found a way to run the solution without giving a specific output folder. I had to fix the output folder path to /bin in the csprojs and then running MSbuild with the solution was able to pick up those paths from the csprojs and build the output into those folders.
谢谢你的答案。我找到了一种方法来运行解决方案而不提供特定的输出文件夹。我必须将输出文件夹路径修复到csprojs中的/ bin,然后运行MSbuild,解决方案能够从csprojs中获取这些路径并将输出构建到这些文件夹中。