3
votes

ASP.NET Core 2 project with docker support added in VS 2017, runs fine locally but build fails in VSTS build with following error:

2018-06-29T16:07:50.4095117Z ##[error]C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Sdks\Microsoft.Docker.Sdk\build\Microsoft.VisualStudio.Docker.Compose.targets(151,5): Error : The project version '2.0' is not supported by the current Visual Studio Tools for Containers.

I am trying to build in Team Services and release to an App Service for Containers in Azure.

docker-compose.dcproj contents:

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" Sdk="Microsoft.Docker.Sdk">
    <PropertyGroup Label="Globals">
    <ProjectVersion>2.0</ProjectVersion>
    <DockerTargetOS>Linux</DockerTargetOS>
    <ProjectGuid>cc9f4ebc-dd9f-4592-9533-b4954b467670</ProjectGuid>
    <DockerLaunchAction>LaunchBrowser</DockerLaunchAction>
    <DockerServiceUrl>http://localhost:{ServicePort}</DockerServiceUrl>
    <DockerServiceName>status</DockerServiceName>
  </PropertyGroup>
  <ItemGroup>
      <None Include="docker-compose.override.yml">
      <DependentUpon>docker-compose.yml</DependentUpon>
    </None>
    <None Include="docker-compose.yml" />
     <None Include=".dockerignore" />
   </ItemGroup>

1
Can you show the whole detail build logs by setting system.debug as true? And can you also share your project (or a example project with the same build error) in one dribe?Marina Liu
@MarinaLiu-MSFT - Example Project - LogsShane

1 Answers

9
votes

Since you are using Hosted VS2017 agent, it only has VS2017 installed and only the windows container for docker can be use. So please make below changes (as the shared example project for example):

  1. Change docker-compose.dcproj file

    • Change ProjectVersion from 2.0 to 2.1
    • Change DockerTargetOS from Linux to Windows
  2. Change docker-compose.yml and docker-compose.override.yml file

    • Change the version from 3 to 3.4

Then the project can build successful by Hosted VS2017 agent. And this is the modified project based on you shared.

BTW: you can also user private agent to build your project. If you can build successful locally, then use the private agent can mostly build the project successfully by VSTS build.