我正在研究网络核心应用程序。我正在使用 docker 在 jenkins 中构建我的应用程序。我的示例存储库位于https://github.com/niranjan2020/JenkinsPipeLine以下是我构建应用程序的命令。docker build -t jenkinspipeline/jenkins -f Dockerfile .下面是我的 .csproj。<Project Sdk="Microsoft.NET.Sdk.Web"> <PropertyGroup> <TargetFramework>netcoreapp2.1</TargetFramework> <DockerDefaultTargetOS>Linux</DockerDefaultTargetOS> <GenerateAssemblyInfo>false</GenerateAssemblyInfo> </PropertyGroup> <ItemGroup> <Folder Include="wwwroot\" /> </ItemGroup> <ItemGroup> <PackageReference Include="Microsoft.AspNetCore.App" /> <PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.1.2" PrivateAssets="All" /> <PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.0.2105168" /> </ItemGroup></Project>当我开始在詹金斯中构建时,出现以下错误obj/Release/netcoreapp2.1/jenkins.RazorAssemblyInfo.cs(11,12):错误CS0579:重复“Microsoft.AspNetCore.Razor.Hosting.RazorLanguageVersionAttribute”属性[/app/jenkins.csproj] obj/Release/netcoreapp2.1 /jenkins.RazorAssemblyInfo.cs(12,12):错误CS0579:重复“Microsoft.AspNetCore.Razor.Hosting.RazorConfigurationNameAttribute”属性[/app/jenkins.csproj]命令“/bin/sh -c dotnetpublish-cRelease” -o输出'返回非零代码:1到目前为止我尝试过的是,删除 bin 和对象文件夹并重建。在.csproj中添加了GenerateAssemblyInfo为 false 重新启动了Jenkins我添加了以下配置https://johnkoerner.com/csharp/dealing-with-duplicate-attribute-errors-in-net-core/
1 回答
陪伴而非守候
TA贡献1757条经验 获得超8个赞
您的存储库中存在多个问题:
清理您的项目,
Jenkins.sln and Jenkins.csproj
您的项目中有多个级别。删除无用的内容。我和你做了一个测试
JenkinsPipeLine\Jenkins\Jenkins
对于 中的 dockerfile
JenkinsPipeLine\Jenkins\Jenkins
,它的镜像是错误的,你的项目目标netcoreapp2.1
,你的镜像应该是mcr.microsoft.com/dotnet/core/sdk:2.1
。dockerfile 是
FROM mcr.microsoft.com/dotnet/core/sdk:2.1 AS build-env
WORKDIR /app
COPY *.csproj ./
RUN dotnet restore
COPY . ./
RUN dotnet publish -c Release -o output
# Runtime image
FROM mcr.microsoft.com/dotnet/core/aspnet:2.1
WORKDIR /app
COPY --from=build-env /app/output .
ENTRYPOINT ["dotnet", "jenkins.dll"]
运行命令docker build -t jenkins -f Dockerfile .从JenkinsPipeLine\Jenkins\Jenkins
- 1 回答
- 0 关注
- 75 浏览
添加回答
举报
0/150
提交
取消