问题描述
首先,让我解释一下导致此问题的问题。
如果我使用 dotnet new
创建一个新项目,并使用指定一个随机项目名称-n
arg,然后在默认bash终端上执行 dotnet恢复
- dotnet构建
之后- >最终输出名称为始终 React
+ .output_type。像这样:
/bin/Debug/netcoreapp2.0/React.dll
我没有使用 dotnet
命令指定任何其他参数。看起来选择什么类型的项目都没有关系:我尝试使用控制台
和 webapi
。 / p>
但是我发现如果我在VS Code中打开项目并执行相同的 dotnet构建VS Code终端(也是bash)中的
命令->输出名称正确,并且等于 project_name + .output_type
。
因此,在我以为在构建过程中总是从 .csproj
文件名获取输出名称之前。但是现在看来,有些东西可以覆盖此行为:不同的终端-不同的环境设置等。
原因输出名称包含 React
我归咎于react cli工具,但这并不能帮助我确定名称覆盖的原因。
我做了来自两个终端的dotnet --info
和输出是相同的:
.NET命令行工具( 2.0.0)
产品信息:
版本:2.0.0
提交SHA-1哈希:cdcd1928c9
运行时环境:
操作系统名称:Mac OS X
操作系统版本:10.13
操作系统平台:Darwin
RID:osx.10.12-x64
基本路径:/ usr / local / share / dotnet / sdk /2.0.0/
感谢@MartinUllrich,我发现 $ TARGETNAME
变量将覆盖项目名称。删除变量可解决问题:
>未设置TARGETNAME
First, let me explain the problem that causes this question.
If I create a new project using dotnet new
and specifying a random project name with -n
arg, then after doing dotnet restore
- dotnet build
from default bash terminal -> the final output name is always React
+ .output_type. Like:
/bin/Debug/netcoreapp2.0/React.dll
I don't specify any additional arguments with dotnet
commands. And looks like it doesn't matter what type of project to select: I have tried with console
and webapi
.
But I have found that if I open the project in VS Code and do the same dotnet build
command from VS Code terminal (that is also bash) -> the output name is correct and equal to the project_name+.output_type
.
So before I thought that output name is always taken from .csproj
file name during building. But now it looks like something could override this behavior: different terminals - different env settings, etc.
Cause output name contains React
I am blaming the react cli tooling, but this doesn't help me with identifying the reason of name-override.
I did dotnet --info
from both terminals and output was the same:
.NET Command Line Tools (2.0.0)
Product Information:
Version: 2.0.0
Commit SHA-1 hash: cdcd1928c9
Runtime Environment:
OS Name: Mac OS X
OS Version: 10.13
OS Platform: Darwin
RID: osx.10.12-x64
Base Path: /usr/local/share/dotnet/sdk/2.0.0/
Thanks to @MartinUllrich, I have found that $TARGETNAME
variable overrides the project name. Removing variable fix the problem:
> unset TARGETNAME
这篇关于dotnet构建如何选择输出名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!