【问题标题】:How to change TargetDir in Visual Studio 2017 netcoreapp2.0?如何在 Visual Studio 2017 netcoreapp2.0 中更改 TargetDir?
【发布时间】:2018-02-17 02:06:27
【问题描述】:

当我构建 netcore 2.0 项目时,VS2017 在\bin\DEBUG\netcoreapp2.0\* 而不是\bin\DEBUG\* 中生成文件。

它在调试时产生海市蜃楼效果,因为生成的应用程序在\bin\DEBUG\ 文件夹中运行。

所以,我要加载的 config.json 文件应该在 \bin\DEBUG\ 文件夹和我的模块文件夹中。

更糟糕的是,我的模块也是 netcore 项目,它们的输出文件夹也在 *\netcoreapp2.0 中。

我发现每次构建项目时都很难手动复制它们。

netcoreapp2.0 有什么方法可以改变 TargetDir 吗? (没有构建后命令)

【问题讨论】:

  • 项目 > 属性 > 构建选项卡,输出路径设置。
  • 它不起作用,编译器总是将 TargetDir 附加到 \netcoreapp2.0 目录

标签: visual-studio-2017 .net-core-2.0


【解决方案1】:

我通过在<PropertyGroup> 标签内添加<AppendTargetFrameworkToOutputPath> 来解决这个问题。由于缺少设置 .csproj 文件的交互式窗口,这是一个老问题,因此应手动编辑该文件。

.csproj 文件的前 5 行应如下所示,

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp2.0</TargetFramework>     
  <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-01-14
    • 2017-09-21
    • 2018-03-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多