C# 重复的“Microsoft.AspNetCore.Razor.Hosting.RazorLanguageVersionAttribute”属性

C# 重复的“Microsoft.AspNetCore.Razor.Hosting.RazorLanguageVersionAttribute”属性,c#,docker,jenkins,asp.net-core,C#,Docker,Jenkins,Asp.net Core,我正在研究网络核心应用程序。我正在使用docker在jenkins中构建应用程序。我的示例存储库位于 下面是我构建应用程序的命令 docker build -t jenkinspipeline/jenkins -f Dockerfile . 下面是我的.csproj <Project Sdk="Microsoft.NET.Sdk.Web"> <PropertyGroup> <TargetFramework>netcoreapp2.1</T

我正在研究网络核心应用程序。我正在使用docker在jenkins中构建应用程序。我的示例存储库位于

下面是我构建应用程序的命令

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>

对我来说什么都不管用。有人能帮我解决这个问题吗?任何帮助都将不胜感激。提前感谢

您的存储库中存在多个问题:

清理您的项目,您的项目中有多个leve Jenkins.sln和Jenkins.csproj。删除无用的内容。 我用你的Jenkins管道做了一个测试\Jenkins\Jenkins 对于Jenkins Pipeline\Jenkins\Jenkins中的dockerfile,其映像是错误的,您的项目目标是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命令。来自Jenkins管道\Jenkins\Jenkins


谢谢周涛。我现在也会更改我需要保存.csproj和sln文件以及docker文件的位置?目前我的路径类似于Jenkins/Jenkins/Jenkins/?那么,最好将文件保存在哪里?@Niranjan将这些文件保存在JenkinsPipeLine\Jenkins\Jenkins中。谢谢。Dockerigone和gitignore也在样本中,对吗?@Niranjan就是这样。
using System;
using System.Reflection;

[assembly: Microsoft.AspNetCore.Mvc.ApplicationParts.RelatedAssemblyAttribute("Jenkins.Views")]
[assembly: Microsoft.AspNetCore.Razor.Hosting.RazorLanguageVersionAttribute("2.1")]
[assembly: Microsoft.AspNetCore.Razor.Hosting.RazorConfigurationNameAttribute("MVC-2.1")]
[assembly: Microsoft.AspNetCore.Razor.Hosting.RazorExtensionAssemblyNameAttribute("MVC-2.1", "Microsoft.AspNetCore.Mvc.Razor.Extensions")]

// Generated by the MSBuild WriteCodeFragment class.
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"]