MSBuild 可以忽略项目引用吗? (BuildProjectReferences 不起作用)
我正在尝试为 .NET 解决方案制作一个构建脚本,该解决方案由多个 C# 项目和一个自定义项目组成。自定义项目可以通过 devenv 构建,但 msbuild 会卡住。
我希望 MSBuild 忽略自定义项目,因为我已经使用 Exec
任务构建它。我实际上需要 MSBuild 甚至不打开自定义 .proj 文件,因为它是 JSON 格式,从而导致 MSBuild 崩溃。
/BuildProjectReferences=false 开关不起作用。 MSBuild 仍尝试读取自定义项目文件。有什么办法解决这个问题吗?
I am trying to make a build script for a .NET solution which consists of several c# projects and one custom project. The custom project can be build by devenv but msbuild chokes on it.
I would like MSBuild to ignore the custom project because I'm already building it with an Exec
task. I actually need MSBuild to not even open the custom .proj file because it's in JSON format and thus causes MSBuild to crash out.
The /BuildProjectReferences=false switch doesn't work. MSBuild still tries to read the custom project file. Is there any way around this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这个问题源于一个项目,该项目有一个 SilverFrost Fortran 项目以及几个 C# 类库。该解决方案只能使用 devenv 进行编译。 Msbuild 会在 Fortran 项目上引发错误,因为它不使用标准 .csproj 格式。
即使 /BuildProjectReferences=false,msbuild 也会尝试读取 Fortran 项目并引发错误。我发现的解决方法是将 msbuild 任务包装在一个 nant 任务中,该任务执行以下操作:
xmlpoke
任务从其他 .csproj 项目中删除对 Fortran 项目的所有引用This question stemmed from a project which had a SilverFrost Fortran project alongside several c# class libraries. The solution would only compile using devenv. Msbuild would throw an error on the Fortran project because it doesn't use the standard .csproj format.
Even with /BuildProjectReferences=false, msbuild would try to read the Fortran project and throw an error. The workaround I discovered was to wrap the msbuild task in an nant task which does the following:
xmlpoke
task不要通过 MSBuild 一次构建解决方案,而是尝试一个一个地构建每个项目。在这种情况下,您可以忽略所需的项目。您还可以在此新脚本中定义自己的基于“Exec”的构建。
Instead of building your solution once by MSBuild, try to build each project one by one. In this case, you can ignore the desired project. You can also define your own "Exec"-based build in this new script.
在使用自定义项目的项目中,您可以右键单击“项目依赖项”并从列表中删除自定义项目吗?您可以改为参考自定义项目的二进制输出。
In your project that uses the custom project, can you right click on the Project Dependencies and remove the custom project from the list? You can refer to the custom project's binary output instead.