gpt4 book ai didi

c# - 带Docker的Asp.Net Core-包含重复的 'Content'项目

转载 作者:行者123 更新时间:2023-12-02 19:08:47 29 4
gpt4 key购买 nike

我想在docker上部署我的应用程序时遇到问题。
我将docker与ASP.Net Core结合使用。

这是一条错误消息:

/usr/local/share/dotnet/sdk/1.0.4/Sdks/Microsoft.NET.Sdk/build/Microsoft.NET.Sdk.DefaultItems.targets(188,5): error : Duplicate 'Content' items were included. The .NET SDK includes 'Content' items from your project directory by default. You can either remove these items from your project file, or set the 'EnableDefaultContentItems' property to 'false' if you want to explicitly include them in your project file. For more information, see https://aka.ms/sdkimplicititems. The duplicate items were: 'wwwroot/_version.txt' [/Users/xxxxxx/Projects/api-test/TestApi/TestApi.csproj]



这是我的csproj
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>netcoreapp1.1.1</TargetFramework>
<DockerComposeProjectPath>..\docker-compose.dcproj</DockerComposeProjectPath>
<UserSecretsId>0a7aa24d-009c-4d0b-b0fd-e8be397b0784</UserSecretsId>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="AutoMapper" Version="6.0.2" />
<PackageReference Include="CoreCompat.System.Drawing" Version="1.0.0-beta006" />
<PackageReference Include="Google.Cloud.Storage.V1" Version="1.1.0-beta01" />
<PackageReference Include="HtmlAgilityPack.NetCore" Version="1.5.0.1" />
<PackageReference Include="MailKit" Version="1.16.1" />
<PackageReference Include="Microsoft.AspNetCore" Version="1.1.2" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.3" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Formatters.Xml" Version="1.1.3" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning" Version="1.1.0-beta2" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="1.1.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="1.1.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="1.1.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.1.2" />
<PackageReference Include="MySql.Data.EntityFrameworkCore" Version="7.0.7-m61" />
<PackageReference Include="RazorLight" Version="1.1.0" />
<PackageReference Include="RazorLight.MVC" Version="1.0.4" />
<PackageReference Include="Serilog" Version="2.5.0-dev-00817" />
<PackageReference Include="Serilog.Extensions.Logging" Version="1.4.1-dev-10155" />
<PackageReference Include="Serilog.Extensions.Logging.File" Version="1.0.1" />
<PackageReference Include="Serilog.Sinks.Console" Version="2.2.0-dev-00721" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="1.0.0" />
<PackageReference Include="Swashbuckle.AspNetCore.Swagger" Version="1.0.0" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="1.0.0" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="1.0.0" />
<PackageReference Include="WkWrap.Core" Version="1.0.2" />
<PackageReference Include="ZXing.Net" Version="0.15.0" />
</ItemGroup>
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="1.0.0" />
</ItemGroup>
<ItemGroup>
<Folder Include="SQL\" />
<Content Include="wwwroot\_version.txt">
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
</Content>
</ItemGroup>
</Project>

我认为问题出在服务器上当前存在的_version.txt文件(我不能说,因为我没有访问权限),并且它试图复制它。

你能帮我吗

最佳答案

默认情况下,.NET SDK包含项目目录中的Content项,因此wwwroot\_version.txt已存在于您的项目中。您的项目文件然后尝试再次添加它,从而导致错误。

您可以使用Update而不是Include来更新现有内容项,而不是对其进行两次包含。

所以,你只需要改变

<Content Include="wwwroot\_version.txt">
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
</Content>


<Content Update="wwwroot\_version.txt">
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
</Content>

关于c# - 带Docker的Asp.Net Core-包含重复的 'Content'项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44126231/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com