带有Docker的Asp.Net Core-包含重复的“内容”项 [英] Asp.Net Core with Docker - Duplicate 'Content' items were included
问题描述
我想在docker上部署我的应用程序时遇到问题。
我在docker上使用ASP.Net Core。
I have a problem when I would like to deploy my app with docker. I'm using ASP.Net Core with docker.
这是一条错误消息:
/usr/local/share/dotnet/sdk/1.0.4/Sdks/Microsoft.NET.Sdk/build/Microsoft.NET.Sdk.DefaultItems.targets(188,5):
错误:包含重复的内容项。 .NET SDK默认情况下包括您项目目录中的
个内容项。您可以
从项目文件中删除这些项目,也可以将
的 EnableDefaultContentItems属性设置为 false,如果您希望
将其明确包含在项目文件中。有关更多信息,
请参见 https://aka.ms/sdkimplicititems 。重复的项目是:
'wwwroot / _version.txt'
[/Users/xxxxxx/Projects/api-test/TestApi/TestApi.csproj]
/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
Here's my 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文件(我可以; t表示那是因为我没有访问权限),并且尝试复制它。
I think the problem is with a _version.txt file which is currently on the server (I can;t say that because I do not have an access) and It tries to duplicate it.
您介意为我提供帮助吗
推荐答案
默认情况下,.NET SDK包含项目目录中的 Content
个项目,因此 wwwroot\_version.txt
已存在于您的项目中。您的项目文件然后尝试再次添加它,这会导致错误。
The .NET SDK includes Content
items from your project directory by default, so wwwroot\_version.txt
is already present in your project. Your project file is then attempting to add it again, which causes the error.
您可以使用 Update
代替包含
导致现有内容项被更新,而不是两次包含。
You can use Update
instead of Include
to cause the existing content item to be updated, rather than including it twice.
因此,您只需要更改
<Content Include="wwwroot\_version.txt">
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
</Content>
到
<Content Update="wwwroot\_version.txt">
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
</Content>
这篇关于带有Docker的Asp.Net Core-包含重复的“内容”项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!