5

Is it possible to build a Visual Studio 2015 extension project on a build server (TeamCity agent) without Visual Studio installed? What kind of SDK do we need to install?

At the moment we receive the following error message:

error MSB4019: The imported project "C:\Program Files (x86)\MSBuild\Microsoft\Portable\v4.6\Microsoft.Portable.CSharp.targets" was not found. Confirm that the path in the declaration is correct, and that the file exists on disk.

So there is definitely some kind of SDK missing.

Daniel Mann
  • 57,011
  • 13
  • 100
  • 120
D.R.
  • 20,268
  • 21
  • 102
  • 205

4 Answers4

2

Microsoft.VSSDK.BuildTools

Contains targets and tools to enable the building of managed VSIX projects without VSSDK MSI installed. Only for VS 2015 and onwards

Additional packages that may be of interest: https://www.nuget.org/profiles/VisualStudioExtensibility

weir
  • 4,521
  • 2
  • 29
  • 42
  • That sounds perfect, however, the NuGet package seems outdated: `Unable to resolve dependencies. 'Microsoft.CodeAnalysis.Analyzers 1.1.0' is not compatible with 'Microsoft.CodeAnalysis.Common 1.0.0 constraint`. – D.R. Mar 17 '16 at 15:49
  • Possibilities: 1) Try adding package [Microsoft.CodeAnalysis.Common 1.1.1](https://www.nuget.org/packages/Microsoft.CodeAnalysis.Common/). 2) Track or participate in the discussion of [this related-looking issue](https://github.com/dotnet/roslyn/issues/9292) in the Roslyn GitHub repository. 3) Seek help from Microsoft in [the extendvs Gitter room](https://gitter.im/microsoft/extendvs). – weir Mar 17 '16 at 17:23
  • I tried this similar to how I handle web apps and it built without errors but didn't actually do anything. – Christopher Painter Aug 08 '17 at 13:39
  • @D.R. - Update: Microsoft appears to have addressed that dependency problem: https://github.com/dotnet/roslyn/pull/16056 – weir Aug 30 '17 at 13:53
  • 1
    Thanks for the info - doesn't look like it is merged yet though. – D.R. Aug 30 '17 at 16:17
2

Using @weir's answer almost worked - the project built successfully, but it failed to produce a VSIX container at the end. For some reason the Nuget package hadn't added the necessary Import to the .csproj to bring in the VsSDK.targets, so the VSIX targets were missing and never got executed.

Here are the steps which worked for me:

  1. Edit the VSIX project .csproj file, and remove Import Project="$(VSToolsPath)\VSSDK\Microsoft.VsSDK.targets" Condition="'$(VSToolsPath)' != ''" />. This will fail on the build server where the VSSDK doesn't exist in the VSToolsPath.
  2. In the VS2015 IDE, open the Nuget Package Manager for the project, and install Microsoft.VSSDK.BuildTools (I used v14.3.25407)
  3. Back in the .csproj file, find the import which the Nuget package added, e.g. <Import Project="..\packages\Microsoft.VSSDK.BuildTools.14.3.25407\build\Microsoft.VSSDK.BuildTools.targets" .../> and add another one below it for the VsSDK.targets file (inside the tools directory), <Import Project="..\packages\Microsoft.VSSDK.BuildTools.14.3.25407\tools\vssdk\Microsoft.VsSDK.targets" .../>
ben
  • 1,441
  • 2
  • 16
  • 21
  • This worked for me - my local & appVeyor builds all worked fine, but not my Travis builds. So I did step 1, omitted step 2 as I already had the nuget package (v15.1.192), then did step 3 (I added `` ) and the Travis build is now successful. [Working example](https://travis-ci.org/GregTrevellick/SolutionOpenPopUp) – Greg Trevellick Aug 19 '18 at 11:58
1

It looks like you have to install the Portable Library Tools on the build agent. You can download them from the VS Gallery and install them without having VS on the build agent using the following parameter /buildmachine.

D.R.
  • 20,268
  • 21
  • 102
  • 205
  • I had the same error. Installed Portable Library Tools. This error disappeared. But according to the link this Portable Library for VS10. I work with VS15. So in build server I have the error "The imported project "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\SSDT\Microsoft.Data.Tools.Schema.SqlTasks.targets" was not found". Where can I find Portable Library Tools for VS15? – RuF Nov 01 '16 at 08:16
0

Download Microsoft Build Tools 2015

unickq
  • 1,497
  • 12
  • 18