0
votes

I've got a machine with .NET Core 1.1.0 1.0.0-preview2-1-003182 installed as well as VisualStudio 2017 RC. When I create a project using "dotnet new -t Console" it requires a project.json file. When I create a .NET Core ConsoleApp in Visual Studio 2017 it requires the .csproj for build configuration. What determines this? I'd like to have one or the other, preferably consistent .csproj since project.json is deprecated for future versions as far as I can tell.

VisualStudio 2017 RC won't seem to build a self-contained executable, so I revert to the command line to attempt a "dotnet publish -t win10-x64" whereby I get the error that there is no project.json. So, even if I have my .csproj configured to build an .exe, I can't just build it.

1
Scott Hanselman did a post, hanselman.com/blog/… more info than the answer below.Lex Li

1 Answers

2
votes

The version of .NET Core Tools is the reason:

  • .csproj is used starting from .NET Core Tools Preview 3

    Note: Visual Studio 2017 RC installs .NET Core Tools Preview 3 (or even Preview 4 now).

  • project.json is used in previous versions.

If you want to know with version of .NET Core Tools is used then go to root project folder and run next command:

dotnet --info

Possible output:

.NET Command Line Tools (1.0.0-preview2-1-003177)

Product Information:
 Version:            1.0.0-preview2-1-003177
 Commit SHA-1 hash:  a2df9c2576

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  10.12
 OS Platform: Darwin
 RID:         osx.10.12-x64

If you have more then one version of .NET Core Tools on your machine, you can directly specify with version should be used for your project by global.json. Create (if not exists) this file in root folder and add "sdk" section. For example for Tools Preview 2:

{
    ...
    "sdk": { "version": "1.0.0-preview2-1-003177" }
}

Also you may use dotnet-migrate command to convert your project.json to .csproj