Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't run console app built for win10-x64 (probably other rids as well) #5916

Closed
BillHiebert opened this issue Apr 29, 2016 · 13 comments
Closed
Assignees
Milestone

Comments

@BillHiebert
Copy link
Contributor

dotnet version: 1.0.0-rc2-002520

Steps to reproduce

  1. New console app
  2. Remove type: platform from dependency
  3. Add runtimes: {"win10-x64" : {}}
  4. dotnet build
    5 Output should be in bin\debug\netcoreapp10\win10-x64
  5. run the built executable

See the following error
Could not resolve coreclr path

@brthor
Copy link
Contributor

brthor commented Apr 29, 2016

New console app

Is this using dotnet new, or a different template?

@BillHiebert
Copy link
Contributor Author

@brthor
A different template. I turned on COREHOST_TRACE and it shows the following (with 1.0.0-rc2-002543):
Checking if CoreCLR path exists=[C:\Users\billhie\AppData\Local\dotnet\runtime\coreclr\coreclr.dll]
Checking if CoreCLR path exists=[C:\Program Files\dotnet\bin\coreclr.dll]
Could not resolve CoreCLR path. For more details, enable tracing by setting COREHOST_TRACE environment variable to 1

Sure enough I don't have a bin folder under c:\program files\dotnet. I did install the SDK which should have included the runtime as well.

@brthor
Copy link
Contributor

brthor commented Apr 29, 2016

Can you share the project.json please?

@BillHiebert
Copy link
Contributor Author

`{
"version": "1.0.0-*",
"compilationOptions": {
"emitEntryPoint": true
},
"runtimes": {
"win10-x64": { }
},
"dependencies": {
"Microsoft.NETCore.App": {
"version": "1.0.0-rc2-3002426"
}
},

"frameworks": {
"netcoreapp1.0": {}
}
}`

I suspect is the platform dependency which is causing the issue

@brthor
Copy link
Contributor

brthor commented Apr 29, 2016

Thanks for the info @BillHiebert , looking into this now

@brthor
Copy link
Contributor

brthor commented Apr 29, 2016

@BillHiebert did you run restore in between steps 3 and 4?

@brthor
Copy link
Contributor

brthor commented Apr 29, 2016

I've reproed this using the following steps (same as yours, but restore step is key):

  1. Create Project.json
{
  "version": "1.0.0-*",
  "compilationOptions": {
    "emitEntryPoint": true
  },
  "runtimes": {
    "win10-x64": { }
  },
  "dependencies": {
    "Microsoft.NETCore.App": {
      "version": "1.0.0-rc2-3002426",
      "type": "platform"
    }
  },

  "frameworks": {
    "netcoreapp1.0": {}
  }
}
  1. dotnet restore
  2. remove "type":"platform"
  3. dotnet build
  4. run bin\Debug\netcoreapp1.0\win10-x64\OUTPUT.exe

The base cause here is that dotnet restore was not run in between steps 3 and 4, and it puts the project in a half-portable, half-standalone state. Build outputs a host and runtimeconfig.json like it's a standalone app but the deps.json reflects a portable app with no coreclr.dll entry.

So immediate workaround is to run dotnet restore between steps 3 and 4, and the fix in build should be to throw an error rather than succeed in this state.

EDIT: I think a better fix is actually to use what has been restored (lock file) and ignore the type:platform removal until that is restored.

brthor referenced this issue in dotnet/cli Apr 29, 2016
This reverts commit 62fd2c5.
brthor referenced this issue in dotnet/cli Apr 29, 2016
@brthor brthor reopened this Apr 29, 2016
@brthor
Copy link
Contributor

brthor commented Apr 29, 2016

dotnet/cli#2781

The issue ended up being simple, build is keying off the wrong things to determine if the project is portable. Now we'll see this error, which tells you to restore again.

I'm not sure if the right thing is for build to succeed here, but this error seems acceptable and matches the state of the project (project.json and project.lock.json are mismatched)

System.InvalidOperationException: Can not find runtime target for framework '.
NETCoreApp,Version=v1.0' compatible with one of the target runtimes: 'win10-x6
4, win81-x64, win8-x64, win7-x64'. Possible causes:
1. The project has not been restored or restore failed - run `dotnet restore`
2. The project does not list one of 'win10-x64, win81-x64, win8-x64, win7-x64'
 in the 'runtimes' section.

@brthor
Copy link
Contributor

brthor commented Apr 30, 2016

After some more testing, this issue goes deeper.. The other fixed bug appears to have been unrelated or a red herring.

When we restore a "type": "platform" dependency, this is reflected in the project.lock.json as "type":"package"

"Microsoft.NETCore.App/1.0.0-rc2-3002426": {
        "type": "package",

However, the lock files generated with and without "type":"platform" are different. Notably "coreclr.dll" is not listed as a native export. What this means is that to the cli, the lock file restored with "type":"platform" appears compatible with the project file without "type":"platform". As far as I can tell, the CLI has no way to determine if there's a mismatch in this scenario.

cc @anurse @emgarten @yishaigalatzer
Is this intentional behavior in NuGet? Is it a bug that "type":"platform" dependencies are listed as "type":"package" in the lock file?

@analogrelay
Copy link
Contributor

analogrelay commented Apr 30, 2016

type in the lock file and type in the project file are completely different properties, they don't correlate.

type:platform implies the NuGet setting exclude:runtime,native which would explain why coreclr.dll is not a native export with type: platform.

/cc @pakrym @davidfowl

@brthor
Copy link
Contributor

brthor commented Apr 30, 2016

type meaning different things in project.json and project.lock.json is pretty confusing.

Knowing that doesn't help solve the problem though. How can we determine from a lock file whether "type": "platform" was specified on the dependency in project.json?

This seems like an important scenario for cli to be able to determine whether the current project file is compatible with the current lock file.

As it exists, the projectFileDependencyGroups from the lock file restored with "type":"platform" match up with the project.json without "type": "platform" causing our validation check to succeed (when it should not):
https://github.com/dotnet/cli/blob/rel/1.0.0/src/Microsoft.DotNet.ProjectModel/Graph/LockFile.cs#L35

EDIT: Added more clarification

@brthor
Copy link
Contributor

brthor commented Apr 30, 2016

@anurse Perhaps the issue here then is not that "type":"package" should be "type":"platform" in the lock file but that the projectFileDependencyGroups should reflect the types of the dependencies.

@TheRealPiotrP TheRealPiotrP changed the title Can't run console up built for win10-x64 (probably other rids as well) Can't run console app built for win10-x64 (probably other rids as well) Apr 30, 2016
brthor referenced this issue in dotnet/cli May 2, 2016
brthor referenced this issue in dotnet/cli May 2, 2016
Verify coreclr absence/presence depending on app type during dotnet build.
brthor referenced this issue in dotnet/cli May 3, 2016
Verify coreclr absence/presence depending on app type during dotnet build.
brthor referenced this issue in dotnet/cli May 3, 2016
Verify coreclr absence/presence depending on app type during dotnet build.
TheRealPiotrP referenced this issue in dotnet/cli May 3, 2016
@iamveritas
Copy link

hi
I am facing this error now

error : Can not find runtime target for framework '
1>.NETCoreApp,Version=v1.0' compatible with one of the target runtimes: 'win10-x6
1>4, win81-x64, win8-x64, win7-x64'. Possible causes:
1>C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\DotNet\Microsoft.Do
1>tNet.Common.Targets(262,5): error : 1. The project has not been restored or res
1>tore failed - run dotnet restore
1>C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\DotNet\Microsoft.Do
1>tNet.Common.Targets(262,5): error : 2. The project does not list one of 'win10-
1>x64, win81-x64, win8-x64, win7-x64' in the 'runtimes' section.

1>C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\DotNet\Microsoft.Do
1>tNet.Common.Targets(262,5): error : 3. You may be trying to publish a library,
1>which is not supported. Use dotnet pack to distribute libraries.

I am sure number 3. suggested is not the case cause I a not trying to publish but build.
number 1. is not either cause the "dotnet restore" succeeds without error.

how do I approach understanding and fixing suggested item 2. ?

thank you

@msftgits msftgits transferred this issue from dotnet/cli Jan 31, 2020
@msftgits msftgits added this to the 1.0.0-rc2 milestone Jan 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants