调试 ASP.NET Core 1.0 应用程序时未找到 Nancyfx 视图
Nancyfx Views not found when debugging ASP.NET Core 1.0 application
在调试模式下使用 Asp.net Core 1.0 解决 Nancyfx 视图时遇到问题。这是因为像wwwroot
这样的文件夹不会输出到bin
文件夹中。我已经用谷歌搜索了,但无论如何都没有找到将文件夹发送到 bin/Debug
的方法。但是,当我发布并 运行 应用程序时,视图得到了很好的解析。这是因为 project.json
我可以配置要输出的文件夹。我知道我可以自定义 ViewLocations
,但如果我这样做是为了让它在 debug
中工作,那么它在 published
.
中将不起作用
这里有几个选项:
设置 ContentRoot
。以下代码使用项目目录作为视图的位置。
public class Program
{
public static void Main(string[] args)
{
var host = new WebHostBuilder()
.UseKestrel()
.UseContentRoot(Directory.GetCurrentDirectory())
.UseIISIntegration()
.UseStartup<Startup>()
.Build();
host.Run();
}
}
您可以使用 project.json
中的 copyToOutput
节点来实现此目的。
示例:
"buildOptions": {
"copyToOutput": {
"include": [
"Areas",
"Views",
"wwwroot",
"config.json",
"web.config"
]
}
在调试模式下使用 Asp.net Core 1.0 解决 Nancyfx 视图时遇到问题。这是因为像wwwroot
这样的文件夹不会输出到bin
文件夹中。我已经用谷歌搜索了,但无论如何都没有找到将文件夹发送到 bin/Debug
的方法。但是,当我发布并 运行 应用程序时,视图得到了很好的解析。这是因为 project.json
我可以配置要输出的文件夹。我知道我可以自定义 ViewLocations
,但如果我这样做是为了让它在 debug
中工作,那么它在 published
.
这里有几个选项:
设置
ContentRoot
。以下代码使用项目目录作为视图的位置。public class Program { public static void Main(string[] args) { var host = new WebHostBuilder() .UseKestrel() .UseContentRoot(Directory.GetCurrentDirectory()) .UseIISIntegration() .UseStartup<Startup>() .Build(); host.Run(); } }
您可以使用
project.json
中的copyToOutput
节点来实现此目的。示例:
"buildOptions": { "copyToOutput": { "include": [ "Areas", "Views", "wwwroot", "config.json", "web.config" ] }