I'm trying to upgrade our buildserver (jenkins) from Visual Studio 2015 to 2017. We're building via MS-Build. I've downloaded and installed MS-Buld tools as described in this answer. If I compile my projects I get an error that Microsoft.WebApplication.targets was not found.
Detailed error:
error MSB4226: The imported project "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\Microsoft\VisualStudio\v15.0\WebApplications\Microsoft.WebApplication.targets"
I performed a find in the MS-Build directory:
PS C:\Program Files (x86)\MSBuild> dir -Recurse -Filter "Microsoft.WebApplication.targets"
Directory: C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\WebApplications
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a---- 11.01.2012 00:23 19654 Microsoft.WebApplication.targets
Directory: C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\WebApplications
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a---- 22.07.2013 01:25 19995 Microsoft.WebApplication.targets
Directory: C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\WebApplications
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a---- 06.07.2015 21:55 20118 Microsoft.WebApplication.targets
Directory: C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\WebApplications
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a---- 22.07.2013 01:25 19995 Microsoft.WebApplication.targets
As can be seen the file exists for old compiler versions, but for v15.0 it is missing.
I also have installed Visual Studio 2017 on the build-server. The project succeeds to build if I compile with Visual Studio 2017.
Any hints how to solve this problem? One possible solution is to generate a symbolic link from C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v15.0\WebApplications point to the old v14.0 files (located under C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\WebApplications).
Thx
Looks like you are missing the workload for "Web development build tools": Microsoft.VisualStudio.Workload.WebBuildTools.
You can install it by downloading the build tools installer from here (VS2017) or here (VS2019) then running
vs_buildtools.exe --add Microsoft.VisualStudio.Workload.WebBuildTools
or opening vs_buildtools.exe and selecting the "Web development build tools" component in the GUI:
The accepted answer above is technically correct just incomplete, a bit confusing, at least for me, and needed one extra step to get Visual Build Professional working.
vs_buildtools.exe does not technically exist. I had to create a question asking where that file was. It was not obvious that vs_buildtools.exe is vs_buildtools_*******.exe and is the actual installation program. Additionally the the "-add ***" mentioned above is just a shorthand. One can go to the GUI and check both workflow tasks. That does the same thing. I wound up having the vs_buildtools file, though not needing it.
VSB Pro still did not build my project. I got thrown the same error above. The secret sauce was simply to copy the WebApplicationsfolder in C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\Microsoft\VisualStudio\v15.0 to C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v15.0. I then rebuilt the project and all was fine. I placed the WebApplication.targets file at the expected location.
Why Microsoft could not have done that is beyond me. Also, why the separate installation. VS17 installs an enormous amount of stuff. Build Tools is implied, like always. Whatever.
I am posting this answer as hopefully it will help others. I fell into the trap and lost quite a bit of time with my project not building. I hope that this answer clarifies things a bit.
I had a similar issue after having upgraded from Visual Studio 2015 to 2017. When I try to load the web application project, it throwed me the error message:
The imported project "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Microsoft\VisualStudio\v14.0\WebApplications\Microsoft.WebApplication.targets" was not found. Also, tried to find "WebApplications\Microsoft.WebApplication.targets" in the fallback search path(s) for $(VSToolsPath) - "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v15.0" . These search paths are defined in "C:\Users\xxx\AppData\Local\Microsoft\VisualStudio\15.0_558e146f\devenv.exe.config". Confirm that the path in the declaration is correct, and that the file exists on disk in one of the search paths.
The solution to this error I found here.
In my case, the .csproj file contained the following lines:
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v14.0</VSToolsPath>
</PropertyGroup>
After replacing the v14.0 by v$(VisualStudioVersion) in the VSToolPath tag, the project could be loaded.
I also replaced the v14.0 by v10.0 in the VisualStudioVersion tag, as the solution in the above link shows. But for me it also worked by leaving it at 14.0.
Here is how these lines should look in the end:
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>
If you don't have these lines at all in your .csproj, then you have to add them manually right BEFORE this line:
<Import Project="$(VSToolsPath)\Web\Microsoft.Web.Publishing.targets" Condition="'$(VSToolsPath)' != ''" />
In my case (slightly different error message but same problem) it was this line:
<Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" />
It seems that projects created with Visual Studio versions since 2011 contain the lines with the VSToolsPath redefinition, while older files did not. Visual Studio never added them automatically when upgrading to a newer VS version, which is why you should add them if they are not there.
Source of this information: https://developercommunity.visualstudio.com/content/problem/27735/project-fails-to-load-with-error-regarding-microso.html?childToView=123664#comment-123664
(click on Show more comments to see the full discussion thread - unfortunately I cannot directly link to comments in this "more" section.)
It is easy to install the 2017 build tools, with the WebBuildTools option already included, using chocolatey. Once you have installed it, type the following in an admin command prompt:
choco install visualstudio2017buildtools -y
For VS 2019, it's similar:
choco install visualstudio2019buildtools -y
For VS 2019, I fixed this by copying:
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VisualStudio\v16.0
to
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio
Copy WebApplications folder from
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0
to
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v15.0
Or in your build script add the following line before compiling
Copy-Item "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\WebApplications" "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v15.0\WebApplications" -Recurse -Force
Be sure to run it with elevated permissions
how to create VS 2017 pro, asp.net MVC application and build it with Jenkins?
use vs 2017 pro in both dev machine and build server
Check that VisualStudio is set to 15
Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v15.0\WebApplications\Microsoft.WebApplication.targets" Condition="false"
set the msbuild tool
to C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\MSBuild.exe in jenkins global configuration manager
With jenkins, execute windows command batch:
retore nugets: "C:\Program Files (x86)\Jenkins\tools\nuget\NuGet.exe" restore "C:\Program Files (x86)\Jenkins\workspace\theapp_build\theapp.sln"
With jenkins, execute windows command batch:
MSBuild Build File: theapp.sln
Command Line Arguments: /nologo /t:restore /t:rebuild /p:Configuration="Debug" /p:VisualStudioVersion=15.0
There can be multiple issues that cause this error, but it is generally due to missing files (example of my error below).
Invalid project `C:\xxxxx\Web.Mvc.csproj`. The imported project "C:\Program Files\dotnet\sdk\5.0.403\Microsoft\VisualStudio\v16.0\WebApplications\Microsoft.WebApplication.targets" was not found. Confirm that the expression in the Import declaration "C:\Program Files\dotnet\sdk\5.0.403\Microsoft\VisualStudio\v16.0\WebApplications\Microsoft.WebApplication.targets" is correct, and that the file exists on disk.
For myself, I am building a .NET 4.8 solution via powershell using the dotnet command, running against VS2019. The failing projects where created in VS2010/15/17.
As such to address the missing files, I simply created a symlink between the files it was looking for and the location it expected.
mklink /J "C:\Program Files\dotnet\sdk\5.0.403\Microsoft\VisualStudio" "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Microsoft\VisualStudio"
This resolved the issue and now I can build solutions programmatically (this should also work for other instances, providing you use the correct file paths to make the symlink).
For Visual Studio 2022 use the following commands with chocolatey:
choco install visualstudio2022buildtools
choco install visualstudio2022-workload-webbuildtools
see also: https://community.chocolatey.org/packages/visualstudio2022-workload-webbuildtools
I just use Visual Studio Installer to update Visual Studio Community 2017, then the problem is solved.
Related
I am seeing some weird behavior with the latest 15.8.2 Visual Studio 2017 Build Tools. After installing the tools and ensuring that it has installed all workloads and components, I attempted to build our master solution from a batch file with the following command:
msbuild %~dp0\..\..\Master.sln /verbosity:quiet /ds /p:Configuration=Debug;Platform=x64 /m /fl1 /fl2 /fl3 /flp1:LogFile="%~dp0\MSBuild.log";Verbosity=normal /flp2:LogFile="%~dp0\ProjectWarnings.log";WarningsOnly /flp3:LogFile="%~dp0\ProjectErrors.log";ErrorsOnly
One of the very first projects fails with the following error:
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\Microsoft\VisualStudio\v15.0\TextTemplating\Microsoft.TextTemplating.targets(340,5): error : System.IO.FileNotFoundException: Could not find a part of the path 'C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\Extensions\Microsoft\SQLDB\DAC\140\Microsoft.SqlServer.TransactSql.ScriptDom.dll'.
If you'll notice, the path that can't be found is looking for the "Enterprise" directory, which obviously doesn't exist because we installed the Build Tools. The .dll in question is there in the correct directory, just under the "BuildTools" folder and not "Enterprise". In the project itself, we have this line for the above .dll:
<HintPath>$(VSInstallDir)\Common7\IDE\Extensions\Microsoft\SQLDB\DAC\140\Microsoft.SqlServer.TransactSql.ScriptDom.dll</HintPath>
When looking at a developer command prompt on the system with just the Build Tools installed, running set, the variable VSInstallDir maps correctly to the BuildTools folder:
VSINSTALLDIR=C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\
My question is this: where in the world is MSBuild getting the "Enterprise" directory from? We are not referencing it in ANY project, instead using $(VSInstallDir) when necessary. I have grepped the entire BuildTools directory for references to "Enterprise" and I'm finding nothing in .targets files or .props (or really any other files) that would indicate the variable would resolve to "Enterprise" rather than "BuildTools".
I am supposed to do an offline installation of vstest.console.exe in the folder path as follows: C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow
I have tried using offline packages such as vs_testagent.exe and vs_testcontroller.exe according to the following link: https://learn.microsoft.com/en-us/visualstudio/install/create-a-network-installation-of-visual-studio. However, these packages do not contain vstest.console.exe.
I am also unable to do a full installation of VS2017 due to space issues. Do anyone have any suggestions? Thanks.
Download the nuget package: Microsoft.TestPlatform, rename it a zip file. Open the zip file, you will find all you need from this folder: .\tools\net451\Common7\IDE\Extensions\TestPlatform, including vstest.console.exe, testhost.**.exe, QTAgent.exe, datacollector.exe.
If you added the nuget package to project, it just downloads the package to packages folder and won't complie to bin, so you have to add a Post-Build event to copy files to bin folder from the packages folder.
You are looking for "Build Tools for Visual Studio" (Microsoft login required). It will give you an installer "vs_BuildTools.exe", which will install by default the build tools in:
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools
(by default)
Two versions of vstest console were installed when I ran it:
...\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe
...\Common7\IDE\Extensions\TestPlatform\vstest.console.exe
I do not know why, nor how they are different. I use the first one.
I used the chocolatey package visualstudio2019testagent to install VS 2019 Test Agent.
Not sure if this would help someone in the future.
Download the Visual Studio Build Tools installer from https://my.visualstudio.com/Downloads?q=build%20tools%20for%20visual%20studio
Run the installer, click the tab Individual components and select Testing tool core features - Build Tools
After installation the vstest.console.exe is located in folder
C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\Common7\IDE\CommonExtensions\Microsoft\TestWindow
Having tried to follow all advices, remedies and workarounds including removing and reinstalling the Multi-Device Hybrid Apps for Visual Studio CPT1 I still can't seem to do a successful build of the included "Blank App (Apache Cordova)" project.
Build ends consistently in one single error:
The command ""C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7
\IDE\Extensions\k04kuuo3.ie0\packages\vs-mda\install" "C:\Program Files (x86)
\nodejs\" "C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7
\IDE\Extensions\k04kuuo3.ie0\packages\vs-mda"" exited with code 8.
File %USERPROFILE%\AppData\Roaming\npm\node_modules\vs-mda-targets\Microsoft.MDA.targets
Line 108
Column 5
Project BlankCordovaApp1
Environment settings:
ADT_HOME %USERPROFILE%\AppData\Local\Android\android-sdk
ANT_HOME C:\apache-ant-1.9.3
GIT_HOME C:\Program Files (x86)\Git\cmd
JAVA_HOME C:\Program Files (x86)\Java\jdk1.7.0_55
PATH %JAVA_HOME%\bin;%ANT_HOME%\bin;%ADT_HOME%\platform-tools;%ADT_HOME%\tools;
C:\Program Files (x86)\nodejs\;C:\Program Files (x86)\Windows Kits\8.1\Windows
Performance Toolkit\;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;
C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.0\
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\
(contains no reference to "Platform")
Your kind help is very much appreciated, Thanks Ian
I just ran into this on one of my PCs and here's how I got it fixed:
Quit Visual Studio
Open the Android SDK manager by typing the Windows key and then "SDK manager", hit enter
Install Android Build Tools Rev 19 by checking the box next to it and clicking Install packages
Accept the license
Open Visual Studio and your project, then run it again
Jordan (Microsoft, Multi-Device Hybrid Apps tools team)
Finally the light bulb went on for me: The problem was the install batch files not being able to locate xcopy.exe and therefore the simple remedy was to just extend the path variable with
%SystemRoot%\system32;
The build now runs without further errors.
Thanks Jordan and Ian.
I ended up doing both.
I ran the Android SDK manager to install the Android Build Tools Rev 19 as well as some other updates.
I also added "%SystemRoot%\system32;" to the PATH environment variable.
Everything running as it should.
I have Visual Studio 2010 Ulitmate (with MSDN Premium), but I can't seem to find this file.
I have tried installing the Visual Studio SDK but I can't seem to find the file.
I have looked in:
C:\Windows\Microsoft.NET\Framework\v3.5
C:\Windows\Microsoft.NET\Framework\v4.0.30319
C:\Program Files (x86)\Microsoft Visual Studio 10.0\SDK\v3.5
But I can't seem to find it.
(In case you are wondering, I need it to perform these steps.)
it should be under C:\Program Files (x86)\MicrosoftSdks\Windows\v7.0a\Bin . You should be able to use wsdl from visual studio command prompt and typing path in visual studio command prompt will give you the locations of all tools that you might need. Hope this helps
Visual Studio 2010 comes with its own command prompt with a lot of functionality ready to use. You can invoke the wsdl command from there
Can't run wdsl.exe directly from the command prompt because it's not in the DOS search path. You will need to explicitly indicate the full path to the wdsl.exe
I haven't tried the code below but you should be able to run it as a prebuild action on your project.
MsBuild script
<Target Name="UpdateWebReference">
<Message Text="Updating Web Reference..."/>
<Exec Command="wsdl.exe /o "e;$(OutDir)"e; /n "e;$(WebServiceNamespace)"e; "e$(PathToWebServiceURL)"e;"/>
</Target>
I'm using EditBin to increase the stack size of an application I'm writing. I have this in the post-build event command line for Visual Studio:
"C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\editbin.exe" /STACK:268435456 "$(TargetPath)"
When I build my project, I get this error:
Error 470 The command ""C:\Program
Files (x86)\Microsoft Visual Studio
10.0\VC\bin\editbin.exe" /STACK:268435456 "[Target Executable]"" exited
with code -1073741515.
I have both of the following in my PATH environment variable:
C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin
The command also works when I run it manually with cmd.exe. Does anyone know what the problem is here?
I had the same issue, how I resolved it:
Ran msbuild.exe <my.sln> /t:<mytargetproject> from a VS2010 command prompt, where <my.sln> is your solution name and <mytargetproject> is the project you are trying to build. For e.g. msbuild.exe helloworld.sln /t:mainproj.
When you do this or at least when I ran this, a dialog box popped up and said "foo.dll" cannot be found, I added the path of that dll to my "PATH" environment variable and the problem was solved! See ChrisF's comment to the question, as it says, the error is that some dll/component is missing.
From the dll name it complained about, I believe this is not contained to VS2010 libs/dlls, for me it was a third-party dll (which I am using and supposed to be available during the build) it was complaining about.
The best solution is to run the vcvarsall.bat located in the root of the visual studio install folder(C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC). That sets up the search folders for all MSVC compiler related tools.
I got this to work for now by copying mspdb100.dll into the same directory as editbin.exe, but this is not an optimal solution because every developer on my team will need to do the same thing.