我有一个使用ubuntu的自托管容器。
FROM ubuntu:18.04
# To make it easier for build and release pipelines to run apt-get,
# configure apt to not require confirmation (assume the -y argument by default)
ENV DEBIAN_FRONTEND=noninteractive
RUN echo "APT::Get::Assume-Yes "true";" > /etc/apt/apt.conf.d/90assumeyes
RUN apt-get update && apt-get install -y --no-install-recommends
ca-certificates
curl
jq
git
iputils-ping
libcurl4
libicu60
libunwind8
netcat
libssl1.0
zip
unzip
&& rm -rf /var/lib/apt/lists/*
RUN curl -LsS https://aka.ms/InstallAzureCLIDeb | bash
&& rm -rf /var/lib/apt/lists/*
# Can be 'linux-x64', 'linux-arm64', 'linux-arm', 'rhel.6-x64'.
ENV TARGETARCH=linux-x64
WORKDIR /azp
COPY ./start.sh .
RUN chmod +x start.sh
ENTRYPOINT ["./start.sh"]
这在azure平台上运行和活动。我正在这个代理上运行一个角度构建管道,并成功运行。
但当我创建一个dotnet核心项目并在此代理上构建时,它会抛出异常。
如果我使用以下内容:
trigger:
- main
pool:
name: PCDOCKER
variables:
solution: '**/*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
projectName: vitrin-api
steps:
- task: NuGetToolInstaller@1
- task: DotNetCoreCLI@2
inputs:
command: 'restore'
feedsToUse: 'select'
vstsFeed: 'my-vsts-feed' # A series of numbers and letters
- task: DotNetCoreCLI@2
inputs:
command: 'build'
arguments: '--configuration $(buildConfiguration)'
displayName: 'dotnet build $(buildConfiguration)'
错误位于DotNetCoreCLI@2步骤:
##[error]Error: Unable to locate executable file: 'dotnet'. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also check the file mode to verify the file is executable.
##[error]Packages failed to restore
如果我使用
- task: NuGetCommand@2
inputs:
restoreSolution: '$(solution)'
而不是DotNetCoreCLI@2,它抛出异常为未找到">单声道";
如何在我的自托管容器上构建我的dotnet应用程序?
要构建.NET Core应用程序,系统上需要提供.NET SDK。NET SDK包括构建和运行应用程序所需的所有必要组件。
若要解决此问题,请在Ubuntu容器上安装.NET SDK
在安装.NET之前,请运行以下命令将Microsoft程序包签名密钥添加到受信任密钥列表中,并添加程序包存储库。
打开终端并运行以下命令:
wget https://packages.microsoft.com/config/ubuntu/21.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
rm packages-microsoft-prod.deb
现在,安装.NET SDK
sudo apt-get update;
sudo apt-get install -y apt-transport-https &&
sudo apt-get update &&
sudo apt-get install -y dotnet-sdk-6.0
查看更多详细信息-https://learn.microsoft.com/en-us/dotnet/core/install/linux-ubuntu#2110-