v11.0\WebApplications\Microsoft.WebApplication.targets was not found when file actually references v10

后端 未结 11 1251
花落未央
花落未央 2020-12-01 01:26

First some background. At the end of 2012 we migrated our vs2008 solution to vs2010 but we still target .NET 3.5. (I know nothing but the latest and greatest here!)

相关标签:
11条回答
  • 2020-12-01 01:49

    If you have a build server that does not have VS2012 installed, you can fix this by

    a) installing the MSBuild.Microsoft.VisualStudio.Web.targets package to your solution, and

    b) replacing this line in the .csproj file:

    <Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" />
    

    With this line pointing to the nuget package

    <Import Project="..\packages\MSBuild.Microsoft.VisualStudio.Web.targets.11.0.2.1\tools\VSToolsPath\WebApplications\Microsoft.WebApplication.targets" Condition="true" />
    

    EDIT

    As @joedragons points out the version in the updated line should match the nuget package version, i.e. replace targets.11.0.2.1 with targets.x.x.x.x for the current version.

    0 讨论(0)
  • 2020-12-01 01:50

    As I was searching how to solve this one, almost everyone recommended either to copy the missing MSBUILD folder or install some SDK of some version.

    Luckily, I've found this awesomely helpful post by Donovan Brown : http://donovanbrown.com/post/So-sick-of-MicrosoftWebApplicationtargets-was-not-found-build-errors!

    In a nutshell, the idea is to configure the VisualStudio version your build should use in your Build Definition:

    Right Click -> "Edit Build Definition..."

    Go to "Procss" -> "3. Advanced"

    and set "MSBuild Arguments" with

    /p:VisualStudioVersion=12.0
    
    0 讨论(0)
  • 2020-12-01 01:52

    I ran into the same issue with Visual Studio 2013. It turns out that I was using the old version of MSBuild--the one that ships with the .NET Framework--from the command line. Microsoft is now releasing MSBuild as part of Visual Studio itself and also as a separate installer (http://blogs.msdn.com/b/visualstudio/archive/2013/07/24/msbuild-is-now-part-of-visual-studio.aspx).

    The solution was to use the new version of MSBuild.exe located in C:\Program Files (x86)\MSBuild\12.0\Bin. Once I did that, all the targets errors disappeared.

    EDIT 1

    As mentioned in the comments, each new version of MSBuild brings with it a new directory. For Visual Studio 2015, use C:\Program Files (x86)\MSBuild\14.0\Bin.

    EDIT 2

    As mentioned in the comments, for Visual Studio 2017, use C:\Program Files (x86)\Microsoft Visual Studio\2017\<Edition>\MSBuild\15.0\Bin\MSBuild.exe.

    0 讨论(0)
  • 2020-12-01 01:54

    I've recently got stuck with the same problem. And my conclusion is that every version of VS (v10, v11, v12) changes path of build variable, like MSBuildBinPath.

    So specifying exact version of VS isn't a hack, because you might not even have appropriate version of files installed. So intead you'd better specify a parameter and use targets that exist on you machine.

    In some rare cases you might need to install specific version of VS and Web Deploy package. In my case just version was enough to solve problem.

    0 讨论(0)
  • 2020-12-01 01:55

    I've found that installing the free Visual Studio 2012 Shell (Isolated) installs the WebApplications v11 MSBuild files. Lighter than a full install of Visual Studio 2012 and no licensing concerns.

    0 讨论(0)
提交回复
热议问题