Sdk: dotnet run after project migration crashes dotnet

Created on 31 Jan 2017  路  7Comments  路  Source: dotnet/sdk

Steps to reproduce

  1. Install d15prerel\26130.0 with no workloads
  2. Install dotnet cli
  3. Download and extract Bala's test repo
  4. In a prompt navigate to \ProjectKTestProjects-master\Dev14_K101\Tooling202\ConsoleAppOnCore_1
  5. dotnet migrate
  6. dotnet restore - dotnet build - dotnet run

Expected behavior

The project starts running

Actual behavior

dotnet crashes

C:\Users\v-sccarl\Documents\ProjectKTestProjects-master\Dev14_K101\Tooling202\AspNetCoreWeb_IndAuth_WithAI_1>dotnet run

Unhandled Exception: System.InvalidOperationException: Couldn't find a project to run. Ensure a project exists in  C:\Users\v-sccarl\Documents\ProjectKTestProjects-master\Dev14_K101\Tooling202\AspNetCoreWeb_IndAuth_WithAI_1.
Or pass the path to the project using --project
   at Microsoft.DotNet.Tools.Run.RunCommand.Initialize()
   at Microsoft.DotNet.Tools.Run.RunCommand.Start()
   at Microsoft.DotNet.Tools.Run.RunCommand.<>c__DisplayClass0_0.<Run>b__0()
   at Microsoft.DotNet.Cli.CommandLine.CommandLineApplication.Execute(String[] args)
   at Microsoft.DotNet.Tools.Run.RunCommand.Run(String[] args)
   at Microsoft.DotNet.Cli.Program.ProcessArgs(String[] args, ITelemetry telemetryClient)
   at Microsoft.DotNet.Cli.Program.Main(String[] args)

Environment data

dotnet --info output:

.NET Command Line Tools (1.0.0-rc4-004707)

Product Information:
 Version:            1.0.0-rc4-004707
 Commit SHA-1 hash:  5aded80a7b

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.14393
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\1.0.0-rc4-004707

Most helpful comment

To run a published app you don't use dotnet run. Dotnet run is a development tool and you need to use it by specifying a csproj or by running it from a folder containing a csproj.

For published apps, if it is a portable app, you run it by doing dotnet . Or, if it is a self-contained app, you simply invoke .[exe].

All 7 comments

@jonsequitur can you address this while fixing dotnet/sdk#7582?

Closing in favor of dotnet/sdk#7582.

image

@piotrpMSFT The change I made fixes this as well.

From visual studio 2017 in debug/release mode running but after publishing the project, these errors are occurring. Can anyone help me here please?
capture

To run a published app you don't use dotnet run. Dotnet run is a development tool and you need to use it by specifying a csproj or by running it from a folder containing a csproj.

For published apps, if it is a portable app, you run it by doing dotnet . Or, if it is a self-contained app, you simply invoke .[exe].

@livarcocc thanks for explanation, saved me from banging my head against the wall too much.

Just in case someone comes across this thread looking for an answer how to make it run on Azure App (and have limited ability to test publish before production publish). Correct me if I'm wrong, cause I kinda figured this out.

When you publish to Azure, you don't need to run anything, if you have this line in web.config:

<aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false"/>

Upon publish, this line gets replaced with:

<aspNetCore processPath="dotnet" arguments=".\NameOfYourMainDLL.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" />

And in this way Azure webserver knows what to run when you request the website. Basically it becomes equivalent to running "dotnet NameOfYourMainDLL.dll" in console when you test publish locally.

That works for me @livarcocc Thanks.

Was this page helpful?
0 / 5 - 0 ratings