none
Building .NETFramework v4.6.2 solution fails in VSTS instance with windows container RRS feed

  • Question

  • Hi,

    I am using Azure Container instance for VSTS Build Server instead VM.

    I am using base image "microsoft/dotnet-framework:4.6.2-windowsservercore-10.0.14393.447"  and provided into your dockerfile.

    I'm experimenting with building my .NET 4.6.2 project with simple console application in a container and MSBuild fails with the following errors:

    C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Microsoft.Common.targets(983,5): warning MSB3644: The reference assemblies for framework ".NETFramework,Version=v4.6.2" were not found. To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed. Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly may not be correctly targeted for the framework you intend

    I have tried with other base images like microsoft/aspnet:4.6.2-windowsservercore-10.0.14393.1715 and microsoft/windowsservercore:10.0.14393.1715 but facing the same issue.

    Thursday, May 17, 2018 1:37 PM

Answers

All replies

  • Are you using hosted VSTS agent or your own VSTS agent?
    Thursday, May 17, 2018 2:00 PM
  • I am using docker image which is capable of acting as a VSTS build agent.
    Thursday, May 17, 2018 2:10 PM
  • What is an image name?
    Thursday, May 17, 2018 2:11 PM
  • Base image name "microsoft/dotnet-framework:4.6.2-windowsservercore-10.0.14393.447"
    Thursday, May 17, 2018 2:13 PM
  • This version seems to be runtime only, you need SDK version and I don't see one available for 4.6.2 for some reason. There is one for 3.5, 4.7.1, 4.7.2 but not 4.6.2
    Thursday, May 17, 2018 2:19 PM
  • Also their runtime image seems to be broken too. It does not have any installation inside docker file. I suggest open issue on github as they note on their docker hub page.

    # escape=`
    
    FROM microsoft/windowsservercore:ltsc2016
    
    ENV COMPLUS_NGenProtectedProcess_FeatureEnabled 0
    RUN \Windows\Microsoft.NET\Framework64\v4.0.30319\ngen update & `
        \Windows\Microsoft.NET\Framework\v4.0.30319\ngen update


    Thursday, May 17, 2018 2:23 PM
  • Actually i am referring https://blogs.msdn.microsoft.com/cesardelatorre/2016/11/18/summary-of-official-microsoft-docker-images-for-net-core-and-net-framework/  

    It is suggesting relevant image according to the application type.


     

    Thursday, May 17, 2018 2:31 PM
  • You are using very old outdated image at most. What are you trying to accomplish? Are you trying to build .NET framework 4.6.2 application then you need to use official images avialable at https://hub.docker.com/r/microsoft/dotnet-framework/ and images which has `sdk` in name has compilers build it. Specifically for 4.6.2 image though neither image with compiler or runtime is available
    Thursday, May 17, 2018 2:37 PM
  • Okay thanks, Let me try this.

    Thursday, May 17, 2018 2:47 PM
  • Now i am using "microsoft/dotnet-framework:4.7.2-sdk-windowsservercore-ltsc2016" image.

    but Nuget package restore task is failing in VSTS.

    Is it something that i missed?

    Below my docker file

    -----------------------------------------------------------------

    # Copyright (C) Microsoft Corporation. All rights reserved.
    # Licensed under the MIT license. See LICENSE.txt in the project root for license information.
    FROM microsoft/dotnet-framework:4.7.2-sdk-windowsservercore-ltsc2016
    SHELL ["powershell.exe", "-ExecutionPolicy", "Bypass", "-Command"]

    ENV VSTS_ACCOUNT=”user”
    ENV VSTS_TOKEN =”password”
    ENV VSTS_AGENT =”https://server.visualstudio.com”
    ENV VSTS_WORK =$COMPUTERNAME
    ENV VSTS_POOL =default 

    ENV TEST_CONTAINER=1 \
        VS_CHANNEL_URI=https://aka.ms/vs/15/release/799c44140/channel \
        VS_BUILDTOOLS_URI=https://aka.ms/vs/15/release/799c44140/vs_buildtools.exe \
        VS_BUILDTOOLS_SHA256=FA29EB83297AECADB0C4CD41E54512C953164E64EEDD9FB9D3BF9BD70C9A2D29 \
        NUGET_URI=https://dist.nuget.org/win-x86-commandline/v4.1.0/nuget.exe \
        NUGET_SHA256=4C1DE9B026E0C4AB087302FF75240885742C0FAA62BD2554F913BBE1F6CB63A0

    # Download nuget.exe
    RUN $ErrorActionPreference = 'Stop'; \
        $ProgressPreference = 'SilentlyContinue'; \
        $VerbosePreference = 'Continue'; \
        New-Item -Path C:\bin -Type Directory | Out-Null; \
        [System.Environment]::SetEnvironmentVariable('PATH', "\"${env:PATH};C:\bin\"", 'Machine'); \
        Invoke-WebRequest -Uri $env:NUGET_URI -OutFile C:\bin\nuget.exe; \
        if ((Get-FileHash -Path C:\bin\nuget.exe -Algorithm SHA256).Hash -ne $env:NUGET_SHA256) { throw 'Download hash does not match' }

    # Download log collection utility
    RUN $ErrorActionPreference = 'Stop'; \
        $ProgressPreference = 'SilentlyContinue'; \
        $VerbosePreference = 'Continue'; \
        Invoke-WebRequest -Uri https://aka.ms/vscollect.exe -OutFile C:\collect.exe


    # Download vs_buildtools.exe
    ADD https://aka.ms/vs/15/release/vs_buildtools.exe C:\\TEMP\\vs_buildtools.exe
    # Install Visual Studio Build Tools
    RUN $ErrorActionPreference = 'Stop'; \
        $VerbosePreference = 'Continue'; \
        $p = Start-Process -Wait -PassThru -FilePath C:\TEMP\vs_buildtools.exe -ArgumentList '--add Microsoft.VisualStudio.Workload.MSBuildTools, --add Microsoft.VisualStudio.Workload.NetCoreBuildTools --remove Microsoft.VisualStudio.Component.Windows10SDK.10240 --remove Microsoft.VisualStudio.Component.Windows10SDK.10586 --remove Microsoft.VisualStudio.Component.Windows10SDK.14393 --remove Microsoft.VisualStudio.Component.Windows81SDK --quiet --nocache --wait --installPath C:\BuildTools'; \
        if ($ret = $p.ExitCode) { c:\collect.exe; throw ('Install failed with exit code 0x{0:x}' -f $ret) }


    # Install agent
    RUN mkdir C:\BuildAgent
    WORKDIR C:/BuildAgent
    COPY start.* ./



    # Use shell form to start developer command prompt and any other commands specified
    SHELL ["cmd.exe", "/s", "/c"]
    ENTRYPOINT C:\BuildTools\Common7\Tools\VsDevCmd.bat && C:\BuildAgent\start.cmd

    # Default to PowerShell console running within developer command prompt environment
    CMD ["powershell.exe", "-nologo"]

    -------------------------------------------------------------------------------------

    Monday, May 21, 2018 4:13 AM
  • It is solved now. able to build solution.

    I have used Nuget Tool Installer with v 4.5.0.

    Thanks

    Monday, May 21, 2018 4:52 AM