设置一个docker MS构建服务器映像

我需要一个用于创建.NET构建服务器映像的Dockerfile的工作示例。

无论我安装什么,当尝试使用容器构建我的项目时,出现以下错误:

错误MSB3644:找不到框架“.NETFramework,Version = v4.5.2”的引用程序集。 要解决此问题,请为此框架版本安装SDK或Targeting Pack,或将您的应用程序重定向到您安装了SDK或Targeting Pack的框架版本。 请注意,程序集将从全局程序集缓存(GAC)中解析出来,并将用于代替引用程序集。 因此,您的程序集可能无法正确定位您想要的框架。

我目前的Dockerfile看起来像这样:

# escape=`
FROM microsoft/dotnet-framework:4.6.2
MAINTAINER xxx@xxx.com

SHELL ["powershell"]

RUN New-Item -ItemType directory -Path "C:tools"

WORKDIR C:tools

RUN Invoke-WebRequest -Uri "https://go.microsoft.com/fwlink/p/?linkid=845298" -OutFile "winsdksetup.exe" -UseBasicParsing
RUN .winsdksetup.exe /q /norestart

# Note: Install .Net 4.5.2
RUN Invoke-WebRequest -Uri "https://download.microsoft.com/download/E/2/1/E21644B5-2DF2-47C2-91BD-63C560427900/NDP452-KB2901907-x86-x64-AllOS-ENU.exe" -OutFile "NDP452-KB2901907-x86-x64-AllOS-ENU.exe" -UseBasicParsing
RUN .NDP452-KB2901907-x86-x64-AllOS-ENU.exe /q /norestart

# Note: Install .Net 4.6.2
RUN Invoke-WebRequest -Uri "https://download.microsoft.com/download/F/9/4/F942F07D-F26F-4F30-B4E3-EBD54FABA377/NDP462-KB3151800-x86-x64-AllOS-ENU.exe" -OutFile "NDP462-KB3151800-x86-x64-AllOS-ENU.exe" -UseBasicParsing
RUN .NDP462-KB3151800-x86-x64-AllOS-ENU.exe /q /norestart

# Note: Install .Net 4.6 Targeting Pack
RUN Invoke-WebRequest -Uri "https://download.microsoft.com/download/C/3/A/C3A5200B-D33C-47E9-9D70-2F7C65DAAD94/NDP46-KB3045557-x86-x64-AllOS-ENU.exe" -OutFile "NDP46-KB3045557-x86-x64-AllOS-ENU.exe" -UseBasicParsing
RUN .NDP46-KB3045557-x86-x64-AllOS-ENU.exe /q /norestart

RUN Invoke-WebRequest "https://download.microsoft.com/download/A/6/3/A637DB94-8BA8-43BB-BA59-A7CF3420CD90/vs_BuildTools.exe" -OutFile "vs_buildtools.exe" -UseBasicParsing
RUN .vs_buildtools.exe --add Microsoft.VisualStudio.Workload.MSBuildTools --quiet --wait

# Note: Add .NET + ASP.NET
RUN Install-WindowsFeature NET-Framework-45-ASPNET ; ` 
Install-WindowsFeature Web-Asp-Net45

# Note: Add NuGet
RUN Invoke-WebRequest "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe" -OutFile "C:toolsnuget.exe" -UseBasicParsing

# Note: Add NUnit
RUN Invoke-WebRequest "https://github.com/nunit/nunit-console/releases/download/3.6.1/NUnit.Console-3.6.1.zip" -OutFile "NUnit.Console-3.6.1.zip" -UseBasicParsing
RUN Expand-Archive "NUnit.Console-3.6.1.zip" -DestinationPath "C:toolsnunit"

# Note: Add DotNet Core
RUN Invoke-WebRequest "https://download.microsoft.com/download/E/7/8/E782433E-7737-4E6C-BFBF-290A0A81C3D7/dotnet-dev-win-x64.1.0.4.zip" -OutFile "dotnet-dev-win-x64.1.0.4.zip" -UseBasicParsing
RUN Expand-Archive "dotnet-dev-win-x64.1.0.4.zip" -DestinationPath "C:toolsdotnet"

# Note: Add to PATH
RUN setx PATH '%PATH%;C:tools;C:toolsdotnet;C:Program Files (x86)Microsoft Visual Studio2017BuildToolsMSBuild15.0Bin'
RUN setx MSBuildSDKsPath 'C:toolsdotnetsdk1.0.4Sdks'

这里缺少什么?


您的dockerfile会安装4.6 Targeting包,但不包含4.5.2的定位包。

这些文件需要位于

C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETFrameworkv4.5.2

为MSBuild正确解决它们

链接地址: http://www.djcxy.com/p/62041.html

上一篇: Setup a docker MS build server image

下一篇: Building VS 2017 MSBuild csproj Projects with Mono on Linux