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

Runtime error after add reference from xproj web app (netcoreapp) to PCL csproj with project.json (netstandard) #6050

Closed
balachir opened this issue May 9, 2016 · 16 comments

Comments

@balachir
Copy link

balachir commented May 9, 2016

Steps to reproduce

Dev14 U2 + DotNetCore RC2 Tooling Preview1 (includes DotNetCli 1.0.0-rc2-002673) + Dev14 micro-update + Nuget 3.5-beta

  1. New .NET Core Console App (xproj targeting netcoreapp 1.0) : ConsoleAppOnCore1
  2. Add new Portable Class Library csproj to the solution : PortableClassLibrary1
    image
  3. Change PCL to target .NET Platform Standard
    -- defaults to netstandard1.2
  4. Add reference from console app to ConsoleAppOnCore1 to PortableClassLibrary1
  5. Build solution
  6. Ctrl-F5

Actual behavior

Solution builds successfully. But following error at runtime. The PortableClassLibrary1.dll is not getting copied over to bin folder of ConsoleAppOnCore1.

image

Repro project :
P2PXprojToCsproj1.zip

Expected behavior

Ctrl-F5 to work successfully

@balachir balachir changed the title Add reference from xproj web app (netcoreapp) to PCL csproj with project.json (netstandard) Runtime error after add reference from xproj web app (netcoreapp) to PCL csproj with project.json (netstandard) May 9, 2016
@livarcocc
Copy link
Contributor

@balachir I can't restore this. Is the repro project missing a NuGet.config? I think this may be working for you because you have the packages in your local cache already. And by working, I mean restoring.

@Sridhar-MS
Copy link
Contributor

Try this NuGet.Config

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <!--To inherit the global NuGet package sources remove the <clear/> line below -->
    <clear />
    <add key="aspnet-release" value="https://www.myget.org/F/aspnetrelease/api/v3/index.json" />
    <add key="api.nuget.org" value="https://api.nuget.org/v3/index.json" />
  </packageSources>
</configuration>

@balachir
Copy link
Author

balachir commented May 9, 2016

Yes you can probably try the NuGet.config that Sridhar provided. The templates in Visual Studio by default do not lay down a NuGet.config. I can also share the repro machine if you need.

@livarcocc
Copy link
Contributor

I just tried this using you repro project with the following versions:

image

image

And this is what I got:

image

Did you do anything else besides what you described that might be causing this?

@balachir
Copy link
Author

I worked offline with Livar on this and he can repro now on his machine with a new project. He's going to continue investigating.

@livarcocc
Copy link
Contributor

Ok, I managed to repro this and I know why this happens.

When VS created the library project, instead of creating it under the src folder (even though I explicitly right-clicked the folder and choose add new project), it is creating it in the solution folder on the same level as the src folder.

The global.json file has as sources only the src and test folders. When it gets converted to a net core project and we add a reference to it, we can't really find it because it is not under one of the folder where we look for dependencies.

For this issue we have two alternatives:

  • Create the library under the src folder, as I thought should have happened.
  • Add "." to the projects folder in the global.json.

I would say both things should happen depending on what the user does.

Also, when we convert the library to core, it is using the wrong version in the netstandard.library dependency. It uses 1.0.0-rc2-23910, which fails restore. It worked for me with 1.5.0-rc2-24027.

image

@livarcocc
Copy link
Contributor

Also, I don't know why restore does not fail in VS for this. I was told that it is calling NuGet directly, so this may be another problem, but when I run dotnet restore with having the project under source and without having "." in the global.json, restore fails for me for the ConsoleApp.

I don't think this is an issue with the CLI at this point.

@barrytang
Copy link

Latest offline investigation seems to indicate this is a CLI issue.

@abpiskunov
Copy link
Contributor

Just tried it with 1.0.0-preview2-002804 , dll of the csproj is copied , but not a pdb file. Debugging will be broken.

@TheRealPiotrP
Copy link
Contributor

@pakrym can you take a look?

@pakrym
Copy link
Contributor

pakrym commented May 20, 2016

@piotrpMSFT: .pdb issue is not connected to .dll issue, I don't know why but csproj references are treated as package references inside CLI (https://github.com/dotnet/cli/blob/rel/1.0.0/src/Microsoft.DotNet.ProjectModel/Compilation/LibraryExporter.cs#L180) and we never copy package pdb's to output.

@abpiskunov
Copy link
Contributor

well, related or not, scenario is still not working as expected, i.e. debug would be broken and users expect pdbs to be copied along with project dlls.

@Eilon
Copy link
Member

Eilon commented May 23, 2016

Unassigning from @pakrym as it's not directly related to his original fix. Is there another engineer that can take this over?

@TheRealPiotrP
Copy link
Contributor

@Eilon I'd ask you that question :) ProjectModel has been owned by @pakrym and peers thus far. Is there someone else that can help?

@TheRealPiotrP
Copy link
Contributor

ping @Eilon if @pakrym is no longer working on ProjectModel issues then can you assign to whomever is?

@abpiskunov
Copy link
Contributor

I fixed it at tooling side after discussing it with Mihai and David via email.

@msftgits msftgits transferred this issue from dotnet/cli Jan 31, 2020
@msftgits msftgits added this to the 1.0.0-preview2 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

9 participants