异常“错误MSB3024:无法复制文件..."尝试使用.Net Core 3.0 SDK(preview5)在DevOps管道中进行构建时引发 [英] Exception "error MSB3024: Could not copy the file..." is thrown when attempting to build in DevOps pipeline using .Net Core 3.0 SDK (preview5)

查看:504
本文介绍了异常“错误MSB3024:无法复制文件..."尝试使用.Net Core 3.0 SDK(preview5)在DevOps管道中进行构建时引发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在DevOps构建管道中构建.Net Core 3.0 (preview)项目.

I am attempting to build a .Net Core 3.0 (preview) project in a DevOps build pipeline.

azure-pipelines.yml中的步骤一直执行到"docker build"步骤,成功启动了构建过程. 读取并执行Docker文件,直至执行"dotnet build"步骤,然后引发以下错误.

The steps in my azure-pipelines.yml executes up to the "docker build" step, successfully initiating the build process. The Docker file is read and executed up to the "dotnet build" step after which the following error is thrown.

错误MSB3024:无法将文件"/src/obj/Release/netcoreapp3.0/"复制到目标文件"/app/",因为目标是文件夹而不是文件.要将源文件复制到文件夹中,请考虑使用DestinationFolder参数而不是DestinationFiles. [/src/.csproj]

error MSB3024: Could not copy the file "/src/obj/Release/netcoreapp3.0/" to the destination file "/app/", because the destination is a folder instead of a file. To copy the source file into a folder, consider using the DestinationFolder parameter instead of DestinationFiles. [/src/.csproj]

我试图通过执行dotnet build".csproj" -c Release -o/app在本地进行构建 然后,构建成功,错误为0,警告为0.这可能与DevOps中的SDK问题有关吗?

I have attempted to build locally by executing dotnet build ".csproj" -c Release -o /app The build then succeeds with 0 errors and 0 warnings. Could this be related to an SDK issue in DevOps?

任何建议将不胜感激.

我的Docker文件中的build命令.

The build command from my Docker file.

RUN dotnet build "<project>.csproj" -c Release -o /app


--- {OMITED}
---1ff83de4bdba
Step 5/16 : WORKDIR /src
---Running in 972629766fad
Removing intermediate container 972629766fad
---1325ecd8e7c3
Step 6/16 : COPY ["<projectname>.csproj", "<projectname>/"]
---a4ba463683dc
Step 7/16 : RUN dotnet restore "<projectname>/<projectname>.csproj"
---Running in 82bb9095d412
Restore completed in 14.08 sec for /src/<projectname>/<projectname>.csproj.
Removing intermediate container 82bb9095d412
---7b0cc236782e
Step 8/16 : COPY . .
---884bb695bfb3
Step 9/16 : WORKDIR /src
---Running in 817b001e2060
Removing intermediate container 817b001e2060
---40b8690ecb63
Step 10/16 : RUN dotnet build "<projectname>.csproj" -c Release -o /app
---Running in 48d79b81c3cb
Microsoft (R) Build Engine version 16.0.462+g62fb89029d for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

Restore completed in 531.02 ms for /src/<projectname>.csproj.
/usr/share/dotnet/sdk/3.0.100-preview5-011568/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.RuntimeIdentifierInference.targets(157,5): message NETSDK1057: You are using a preview version of .NET Core. See: https://aka.ms/dotnet-core-preview [/src/<projectname>.csproj]
/usr/share/dotnet/sdk/3.0.100-preview5-011568/Microsoft.Common.CurrentVersion.targets(4560,5): error MSB3024: Could not copy the file "/src/obj/Release/netcoreapp3.0/<projectname>" to the destination file "/app/<projectname>", because the destination is a folder instead of a file. To copy the source file into a folder, consider using the DestinationFolder parameter instead of DestinationFiles. [/src/<projectname>.csproj]

Build FAILED.

/usr/share/dotnet/sdk/3.0.100-preview5-011568/Microsoft.Common.CurrentVersion.targets(4560,5): **error MSB3024: Could not copy the file "/src/obj/Release/netcoreapp3.0/<projectname>" to the destination file "/app/<projectname>", because the destination is a folder instead of a file. To copy the source file into a folder, consider using the DestinationFolder parameter instead of DestinationFiles. **[/src/<projectname>.csproj]
    0 Warning(s)
    1 Error(s)

Time Elapsed 00:00:11.43
The command '/bin/sh -c dotnet build "<projectname>.csproj" -c Release -o /app' returned a non-zero code: 1
##[error]Bash exited with code '1'.
##[section]Finishing: docker build

推荐答案

在我的情况下,我不得不重命名项目文件夹,以使其与dockerfile中的项目本身不同:

in my case i had to rename the project folder to be different than the project itself in dockerfile:

FROM mcr.microsoft.com/dotnet/core/sdk:3.0 AS build
WORKDIR /src
COPY ["<project-name>.csproj", "<project-name>_build/"]
RUN dotnet restore "<project-name>_build/<project-name>.csproj"

这篇关于异常“错误MSB3024:无法复制文件..."尝试使用.Net Core 3.0 SDK(preview5)在DevOps管道中进行构建时引发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆