Setiap kali saya menambahkan file javascript atau css ke proyek inti asp.net saya dan saya jalankan dotnet run
di terminal bash saya, saya mendapatkan kesalahan berikut:
/usr/share/dotnet/sdk/1.0.1/Sdks/Microsoft.NET.Sdk/build/Microsoft
.NET.Sdk.DefaultItems.targets (188,5): error: Duplikat 'Konten' disertakan. .NET SDK menyertakan item 'Konten' dari direktori proyek Anda secara default. Anda dapat menghapus item-item ini dari file proyek Anda, atau mengatur properti 'EnableDefaultContentItems' menjadi 'false' jika Anda ingin secara eksplisit memasukkannya dalam file proyek Anda. Untuk informasi lebih lanjut, lihat https://aka.ms/sdkimplicititems . Item duplikat adalah: 'wwwroot / css / BasicQuotation.css'; 'wwwroot / js / BasicQuotation.js' [/mnt/c/Dev/myproject/MyProject/MyProject.csproj]
Bangunan gagal. Harap perbaiki kesalahan pembuatan dan jalankan kembali.
Saya dapat memperbaikinya dengan menghapus ItemGroup
dari file csproj saya, tetapi saya rasa itu tidak produktif.
Ini terjadi dalam template Visual Studio 2017 ASP.NET Core Web Application (.NET Core) default. Saya menambahkan file ke proyek saya dengan mengklik kanan folder wwwroot> js dan kemudian pilihAdd > New Item > JavaScript File
Ini adalah file .csproj saya:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp1.1</TargetFramework>
</PropertyGroup>
<PropertyGroup>
<PackageTargetFallback>$(PackageTargetFallback);portable-net45+win8+wp8+wpa81;</PackageTargetFallback>
</PropertyGroup>
<PropertyGroup>
<UserSecretsId>aspnet-MyProject-7e1906d8-5dbd-469a-b237-d7a563081253</UserSecretsId>
</PropertyGroup>
<ItemGroup>
<Compile Remove="wwwroot\lib\jquery-validation\**" />
<Content Remove="wwwroot\lib\jquery-validation\**" />
<EmbeddedResource Remove="wwwroot\lib\jquery-validation\**" />
<None Remove="wwwroot\lib\jquery-validation\**" />
</ItemGroup>
<ItemGroup>
<Content Include="wwwroot\css\BasicQuotation.css" />
<Content Include="wwwroot\js\BasicQuotation.js" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore" Version="1.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.Cookies" Version="1.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="1.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.2" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="1.1.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="1.1.1" PrivateAssets="All" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="1.1.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer.Design" Version="1.1.1" PrivateAssets="All" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="1.1.0" PrivateAssets="All" />
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="1.1.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.1.1" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="1.1.0" PrivateAssets="All" />
</ItemGroup>
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="1.0.0" />
<DotNetCliToolReference Include="Microsoft.Extensions.SecretManager.Tools" Version="1.0.0" />
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="1.0.0" />
</ItemGroup>
<ItemGroup>
<Folder Include="Data\Commands\" />
<Folder Include="Data\Queries\" />
<Folder Include="wwwroot\images\" />
</ItemGroup>
</Project>