2

Following this guide I installed the Build Tools into the container using the --all option.

Additionally I am installing the Azure Pipelines Agent service into the container on start-up.

Now I have 2 problems:

  • The scanning part of the Azure Pipelines agent which detects the capabilities, does not find/add the "vstest" capability but it seems to be there as I do find the vstest.console.exe within the container. Any ideas what may be missing or why it is not detected correctly?

  • SSDT has not been installed. Searched for it in the container - nothing. How could this be when --all is being used? It should be part of the package, as it shows the data workloads in the install wizard. ##[error]The nuget command failed with exit code(1) and error(C:\azp\agent\_work\2\s\src\Something.Database\Something.Database.sqlproj(52,57): error MSB4226: The imported project "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Microsoft\VisualStudio\v11.0\SSDT\Microsoft.Data.Tools.Schema.SqlTasks.targets" was not found. Also, tried to find "Microsoft\VisualStudio\v11.0\SSDT\Microsoft.Data.Tools.Schema.SqlTasks.targets" in the fallback search path(s) for $(MSBuildExtensionsPath) - "C:\Program Files (x86)\MSBuild" . These search paths are defined in "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\Bin\msbuild.exe.Config". Confirm that the path in the <Import> declaration is correct, and that the file exists on disk in one of the search paths.

timmkrause
  • 3,367
  • 4
  • 32
  • 59

2 Answers2

2

I went into this direction, so I used this Dockerfile by lukas-lansky as a starting point.

As I already mentioned I added the Azure Pipelines Agent part on top of it.

As I needed to build a full solution with Web Deploy packaging, including database projects (SSDT) and had to run tests, I needed to adjust lukas-lanskys command line call to vs_community.exe slightly:

RUN & "$env:TEMP\vs_community.exe" --add Microsoft.VisualStudio.Workload.NetWeb --includeRecommended --quiet --wait --norestart --noUpdateInstaller | Out-Default

You have to know that only Required components of a workload (ID) are installed by default. Workload and component IDs supported by the installer are documented here. Because of this behavior Web Deploy was missing. So I added the --includeRecommended option to bring in Web Deploy.

timmkrause
  • 3,367
  • 4
  • 32
  • 59
1

what may be missing or why it is not detected correctly?

Since not know too much on your self-agent's configuration, and in fact, the task does not consider the capability value, it will attempt to find the tool automatically.

You could add some scripts manually to make it be detected.

Just go the bin file of your agent, then add a file named Add-VisualStudioTestCapabilities.ps1 under powershell folder:(Please replace its corresponding path on your side)

enter image description here

[CmdletBinding()]
param()

if (Test-Path ":\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TestWindow") {
    Write-Capability -Name 'VSTest' -Value ":\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TestWindow"
}

And restart the agent.


error MSB4226: The imported project "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Microsoft\VisualStudio\v11.0\SSDT\Microsoft.Data.Tools.Schema.SqlTasks.targets" was not found

This is a very normal message when SSDT does not exists.

See this blog.

SSDT only support VS Community, Professional and Enterprise. VS Build Tools lacks some necessary components.

Mengdi Liang
  • 17,577
  • 2
  • 28
  • 35
  • Thank you for your detailed insights. I will try those out. It's really weird that the Build Tools do not deliver the necessary stuff. There is even an option in the GUI installer called "SQL Server Data Tools: Buildtools", but obviously the "Buildtools" variant is lacking some of the components as you mentioned. – timmkrause Feb 10 '20 at 11:21
  • As the image was based on `mcr.microsoft.com/dotnet/framework/sdk:4.8-windowsservercore-ltsc2019` the "Test Agent" was installed. This tooling (and the `vstest.console.exe` sits inside `Microsoft Visual Studio\TestAgent\...\TestWindow`. This path is not incorporated in the scanning process. Using your approach I did it manually. But weird error message were shown during build. There also seem some components missing to execute tests. Because of this **and** your answer regarding SSDT, I have chosen another direction which I will document in another answer. – timmkrause Feb 12 '20 at 15:28
  • Thank you again for the insights regarding the capability scanning process. This was an interesting journey for me. – timmkrause Feb 12 '20 at 15:42
  • @timmkrause It’s welcome! Pity for bring another error to you, but still awesome to know you got the guide finally:-) – Mengdi Liang Feb 12 '20 at 15:44