.NET错误CS1514在Docker构建申请时
我有一个带有文件枚举的.NET5项目:
namespace App.Enums;
public enum Enum1
{
Item1 = 0,
Item2 = 1,
Item3 = 2,
Item4 = 3,
Item5 = 4
}
当我尝试运行时:
RUN dotnet publish -c Release -o out
我收到错误:
Enum.cs(3,27): error CS1514: { expected
该项目在Windows 11上通常在Docker外面建造。如何在Docker中构建它?
I have a .NET5 project with a file Enum.cs like this:
namespace App.Enums;
public enum Enum1
{
Item1 = 0,
Item2 = 1,
Item3 = 2,
Item4 = 3,
Item5 = 4
}
When I try to run:
RUN dotnet publish -c Release -o out
I receive the error:
Enum.cs(3,27): error CS1514: { expected
The project builds normally outside Docker at Windows 11. How can I build it inside Docker?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我发现,如果我将课程更改为此格式,则解决了问题:
另一个解决方案是使用.NET 6.0 SDK。
I discovered that if I change the class to this format the problem is solved:
Another solution is using the .net 6.0 SDK.
我在码头容器中构建构建类似的问题,而本地在VS Studio中进行的一切都很好。该项目是Roslyn 3.1上的净3.1核心。而不是枚举班级。
另外,不支持文件划分的语法。
我必须将其更改为旧语法。
I had a similar problem with building in a docker container, while locally in vs studio everything ran fine. The project was Net 3.1 core on roslyn 3.1. Instead of enum there was the class.
Also, file-scoped syntax was not supported.
I had to change it to the old syntax.