我刚更新到Visual Studio 2017 v15.3
和Core 2.0 SDK
。Visual Studio 2017 v15.3不复制nlog.config
我与Igans Sakalauskas' Net Core Knockout project
工作,它与Core 1.1
建于2017年VS
https://ignas.me/tech/net-core-knockoutjs-web-application/
我已经离开EnableDefaultContentItems
到的真实的默认和删除Content Include
语句从.csproj
文件在WebApplication1.Web
项目中。
他正在使用nlog
,并且项目的根目录中有nlog.config
。该项目成功建立,但运行时抛出file not found error
。它正在寻找WebApplication1.Web\bin\Debug\netcoreapp1.1
文件夹中的nlog.config
。如果我手动复制项目运行的文件并通过所有测试。
我无法工作的是VS在项目构建时复制nlog.config
。
如果我添加
<ItemGroup>
<Content Include="nlog.*" />
</ItemGroup>
到.csproj
我得到的Duplicate 'Content' items ... The duplicate items were: 'nlog.config'
错误。 https://aka.ms/sdkimplicititems
如果我注释掉Contnet Include
并设置EnableDefaultContentItems
假
<PropertyGroup>
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
</PropertyGroup>
我得到一个 Suppression State Error CS5001 Program does not contain a static 'Main' method suitable for an entry point
如果我再恢复'内容Inculde的陈述就给出了这样的错误:
Duplicate 'Content' items ... The duplicate items were: 'list of files'
错误
Default Content Items
正在wwwroot
子文件夹中使用.js
和.cs
文件。
如果VS抛出Duplicate Content
错误当我Content Include
一个项目为什么它不复制文件没有Content Include
?
在VS 2017中15.3如何配置文件nlog.config
从项目根目录复制到bin子目录?
你好Daniel。我刚刚发布了我的答案,即在VS'nlog.config'中突出显示,并在Properties中将Copy to Output Directory状态更改为将您的答案写入'.csproj'。但你击败了我,所以你得到了投票。仍然没有回答为什么设置“EnableDefaultContentItems”为false的第二个问题不起作用。你有什么想法吗?请让我知道,所以如果你不知道,我会知道发布一个单独的问题。 – Joe
@Joe最可能的问题是:'EnableDefaultCompileItems'不在正确的位置,没有被应用,或者内容包含问题。通过删除内容包含并删除“EnableDefaultCompileItems”来避免整个问题是最容易的,这对我来说非常有效,我还没有发现需要EnableDefaultCompileItems。 –