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

PackageReference doesn't work on .NET 4.5.2 console app #4163

Closed
clairernovotny opened this issue Dec 29, 2016 · 20 comments
Closed

PackageReference doesn't work on .NET 4.5.2 console app #4163

clairernovotny opened this issue Dec 29, 2016 · 20 comments
Assignees
Labels
Resolution:Duplicate This issue appears to be a Duplicate of another issue Style:PackageReference Type:Bug
Milestone

Comments

@clairernovotny
Copy link

In VS 2017 RC2

Create a new .NET 4.5.2 console app. Manually add a PackageReference to the csproj and compile. You get the following error:

1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Microsoft\NuGet\15.0\Microsoft.NuGet.targets(162,5): error : Your project.json doesn't have a runtimes section. You should add '"runtimes": { "win": { } }' to your project.json and then re-run NuGet restore.

@emgarten
Copy link
Member

@onovotny try adding this to your project:

<PropertyGroup>
  <RuntimeIdentifiers>win</RuntimeIdentifiers>
</PropertyGroup>

@jainaashish is the default added in the latest build task? Should the message be updated also to include non-project.json based projects.

@rrelyea rrelyea added this to the 4.0 RC3 milestone Dec 29, 2016
@rrelyea rrelyea added Style:PackageReference Type:Bug Resolution:Duplicate This issue appears to be a Duplicate of another issue labels Dec 29, 2016
@rrelyea
Copy link
Contributor

rrelyea commented Dec 29, 2016

Yes, the next RC update will have this, or similar, via targets files.
So perhaps you want to make your temporary workaround conditioned on RuntimeIdentifiers not being set?

@rrelyea rrelyea closed this as completed Dec 29, 2016
@clairernovotny
Copy link
Author

Okay, thanks, that worked!

@markusgud
Copy link

We had this problem too. We were changing targeting from .NET Core Project back to the VS2012 project format. For some reason there was a file obj/project.assets.json that was not deleted on "Clean Solution".

Once we deleted this file manually, the problem was gone.

@den-run-ai
Copy link

@markusgud deleting project.assets.json worked great! In my case I had both solutions open with different msbuild systems. Using one solution at a time fixes the issues.

@brucechase
Copy link

I wouldn't be so fast in deleting this error. I cannot get rid of the error from VS 15.4/C# even after following all the above steps multiple times. I am at a loss of what to do... 3 hours into this and I cannot compile the application. I have deleted the project.*.json files and project.json file; updated those files with the "win10" addition to "runtimes"; attempted to restore nuget; changed nuget files; rebooted; restarted; you-name-it. And all I get is the same error: "Your project.json doesn't have a runtimes section. You should add '"runtimes": { "win10": { } }' to your project.json and then re-run NuGet restore."

@jainaashish
Copy link
Contributor

@brucechase Are you using PackageReference to manage your dependencies or project.json file? And if you were using project.json file then why will you delete that? that will cause even more troubles. Can you share your sample solution or detailed steps to repro your issue?

@brucechase
Copy link

brucechase commented Oct 26, 2017 via email

@LightBender
Copy link

I just ran into this as well. If you have a old-style csproj that references a new style csproj (any project with transitive references) go to the obj folder for the old-style csproj, delete the project.assets.json file and rebuild. That worked for me.

@brucechase
Copy link

brucechase commented Oct 27, 2017 via email

@jainaashish
Copy link
Contributor

Is it possible for you to share your project file removing private data? And it looks like your issue is different than what this issue is about so please log a separate issue with all the details.

@brucechase
Copy link

brucechase commented Oct 27, 2017 via email

@evil-shrike
Copy link

evil-shrike commented Oct 27, 2017

I'm having the same error in my solution with mixed old and new style csproj while I build it via msbuild (as building via dotnet doesn't work for VSSDK-projects). Please see details here:
https://developercommunity.visualstudio.com/content/problem/138372/vsix-cant-build-solution-with-mixed-style-csproj-p.html

UPDATE:
adding

<PropertyGroup>
  <RuntimeIdentifiers>win</RuntimeIdentifiers>
</PropertyGroup>

into EVERY (old-styled) csproj helps me!

@brucechase
Copy link

brucechase commented Oct 27, 2017 via email

Belorus added a commit to Belorus/EventStream that referenced this issue Nov 17, 2017
@rianjs
Copy link

rianjs commented Dec 6, 2017

I don't know why this was closed. It's still a problem.

@shoff
Copy link

shoff commented Feb 23, 2018

Huge problem still for me trying to convert a project to use PackageReference from packages.config. Lot's of Method XXX of interface XXX does not implement method etc etc. When obviously they do.

@304NotModified
Copy link

304NotModified commented Apr 10, 2018

I wouldn't be so fast in deleting this error. I cannot get rid of the error from VS 15.4/C# even after following all the above steps multiple times. I am at a loss of what to do... 3 hours into this and I cannot compile the application. I have deleted the project.*.json files and project.json file; updated those files with the "win10" addition to "runtimes"; attempted to restore nuget; changed nuget files; rebooted; restarted; you-name-it. And all I get is the same error: "Your project.json doesn't have a runtimes section. You should add '"runtimes": { "win10": { } }' to your project.json and then re-run NuGet restore."

I've still the same problem.

<PropertyGroup>
  <RuntimeIdentifiers>win</RuntimeIdentifiers>
</PropertyGroup>

Won't fix it for me :(

also clean bin, obj etc folders, still this error

update: closed as duplicate, where is the duplicate?

update2: this worked for me: git clean -fxd

@jainaashish
Copy link
Contributor

@304NotModified when it's throwing error for win10 then you would need to add <RuntimeIdentifiers>win10</RuntimeIdentifiers> to resolve this instead of just win.

Besides with latest visual studio 2017 15.6 you shouldn't need to explicitly set this workaround. If you're still seeing this issue with latest VS, then please provide more details:

  • VS version
  • Type of project where you see this issue (UAP or full desktop framework)
  • Run msbuild /pp:pp.txt command from developer command prompt on this failing csproj file and share the pp.txt file.

@304NotModified
Copy link

I had the problem with 15.6.5 and 15.6.6

It was .net class library.

If the issue is back, I will post the pp command log.

@flcdrg
Copy link

flcdrg commented Apr 12, 2018

I was getting this error on our build server. It seems to be related to the fact that the particular build agent had the following entries in the system PATH environment variable:

C:\Program Files (x86)\MSBuild\14.0\Bin
C:\Program Files (x86)\MSBuild\

Removing them (and rebooting the agent) appears to have resolved the problem. Another build agent (that didn't have these in PATH was not experiencing this issue)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution:Duplicate This issue appears to be a Duplicate of another issue Style:PackageReference Type:Bug
Projects
None yet
Development

No branches or pull requests