How dotnet build chooses the output name

Viewed 1026

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/
1 Answers

Thanks to @MartinUllrich, I have found that $TARGETNAME variable overrides the project name. Removing variable fix the problem:

> unset TARGETNAME
Related