Force a tool version with MSBuild from inside the file?

戏子无情 提交于 2019-12-23 10:19:33

问题


I've moved my project over to .NET 4.0 recently, and am having some trouble running the ASP.NET compiler inside of my build. This doesn't work because MSBuild by default uses an old tools version when running the ASP.NET Compiler.

I've been able to address it my specifying the tools version explicitly (yes, I'm running MSBuild 4.0) like so:

msbuild /t:MyTarget /tv:4.0 mybuildfile.msbuild

Is there any directive I can use from within the build file itself which will allow me to call msbuild in a more plain vanilla fashion like so?

msbuild /t:MyTarget mybuildfile.msbuild

回答1:


Set the project ToolsVersion to 4.0 in your msbuild file :

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
   ...
</Project>


来源:https://stackoverflow.com/questions/2819781/force-a-tool-version-with-msbuild-from-inside-the-file

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