首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何修复我的dockerfile上的'MSBUILD : error MSB1011‘?

如何修复我的dockerfile上的'MSBUILD : error MSB1011‘?
EN

Stack Overflow用户
提问于 2019-08-12 19:17:17
回答 1查看 2K关注 0票数 1

我正在设置这个示例后面的dockerfile。我被困在下面的命令里了。

我的项目最初不包含csproj文件.

控制台

代码语言:javascript
运行
复制
Sending build context to Docker daemon  101.6MB
Step 1/10 : FROM mcr.microsoft.com/dotnet/framework/sdk:4.8 AS build
 ---> 161680d5c6b2
Step 2/10 : WORKDIR /app
 ---> Using cache
 ---> c72d80e3abed
Step 3/10 : COPY *.sln .
 ---> Using cache
 ---> 06bbfc478b4c
Step 4/10 : COPY *.config ./
 ---> Using cache
 ---> f2ebd7396f5a
Step 5/10 : RUN nuget restore
 ---> Using cache
 ---> f3e33c0d2590
Step 6/10 : COPY . ./
 ---> fc8fe6acd4a3
Step 7/10 : RUN msbuild /p:Configuration=Release
 ---> Running in fe213a4b69d5

Microsoft (R) Build Engine version 16.2.32702+c4012a063 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.

MSBUILD : error MSB1011: Specify which project or solution file to use because this folder contains more than one project or solution file.
The command 'powershell -Command $ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue'; msbuild /p:Configuration=Release' returned a non-zero code: 1

我通过构建解决方案并使用IIS express (它运行得很顺利)在本地运行它,但我的dockerfile不是。下面是我的dockerfile,其中包含一些说明。

Dockerfile

代码语言:javascript
运行
复制
FROM mcr.microsoft.com/dotnet/framework/sdk:4.8 AS build
WORKDIR /app

# copy csproj and restore as distinct layers
COPY *.sln .
# COPY aspnetapp/*.csproj ./aspnetapp/
COPY *.config ./
RUN nuget restore

# copy everything else and build app
COPY . ./
# WORKDIR /app
RUN msbuild /p:Configuration=Release


FROM mcr.microsoft.com/dotnet/framework/aspnet:4.8 AS runtime
WORKDIR /inetpub/wwwroot
COPY --from=build /app ./

项目结构

代码语言:javascript
运行
复制
/aspnetapp
├── *.aspx
├── *.aspx.cs
├── App_Code
├── App_Data
├── Documents
├── *.master
├── *.master.cs
├── Scripts
├── Styles
├── Templates
├── *.sln
├── assetinfo.json
├── bin
├── dockerfile
├── images
├── js
├── media
├── packages
├── package.config
├── web.config
└── *.publishproj

非常感谢你的回答。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-08-12 19:22:50

您有多个项目和/或解决方案,可以在工作目录中构建这些项目和/或解决方案。在这种情况下,您可以提供直接构建在dockerfile中的解决方案的名称。

代码语言:javascript
运行
复制
RUN msbuild /p:Configuration=Release mySolution.sln

代码语言:javascript
运行
复制
RUN msbuild /p:Configuration=Release myProject.csproj

这两种方法都可以帮助您通过构建,或者至少帮助您解决可能面临的下一个问题。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/57467033

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档