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
onovotny opened this Issue Dec 29, 2016 · 20 comments

Comments

@onovotny

onovotny commented Dec 29, 2016

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

This comment has been minimized.

Show comment
Hide comment
@emgarten

emgarten Dec 29, 2016

Collaborator

@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.

Collaborator

emgarten commented Dec 29, 2016

@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

This comment has been minimized.

Show comment
Hide comment
@rrelyea

rrelyea Dec 29, 2016

Contributor

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?

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 Dec 29, 2016

@onovotny

This comment has been minimized.

Show comment
Hide comment
@onovotny

onovotny Dec 29, 2016

Okay, thanks, that worked!

onovotny commented Dec 29, 2016

Okay, thanks, that worked!

@markusgud

This comment has been minimized.

Show comment
Hide comment
@markusgud

markusgud Aug 18, 2017

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.

markusgud commented Aug 18, 2017

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.

@denfromufa

This comment has been minimized.

Show comment
Hide comment
@denfromufa

denfromufa Sep 13, 2017

@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.

denfromufa commented Sep 13, 2017

@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

This comment has been minimized.

Show comment
Hide comment
@brucechase

brucechase Oct 26, 2017

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."

brucechase commented Oct 26, 2017

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

This comment has been minimized.

Show comment
Hide comment
@jainaashish

jainaashish Oct 26, 2017

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?

Contributor

jainaashish commented Oct 26, 2017

@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

This comment has been minimized.

Show comment
Hide comment
@brucechase

brucechase Oct 26, 2017

brucechase commented Oct 26, 2017

@LightBender

This comment has been minimized.

Show comment
Hide comment
@LightBender

LightBender Oct 26, 2017

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.

LightBender commented Oct 26, 2017

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

This comment has been minimized.

Show comment
Hide comment
@brucechase

brucechase Oct 27, 2017

brucechase commented Oct 27, 2017

@jainaashish

This comment has been minimized.

Show comment
Hide comment
@jainaashish

jainaashish Oct 27, 2017

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.

Contributor

jainaashish commented Oct 27, 2017

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

This comment has been minimized.

Show comment
Hide comment
@brucechase

brucechase Oct 27, 2017

brucechase commented Oct 27, 2017

@evil-shrike

This comment has been minimized.

Show comment
Hide comment
@evil-shrike

evil-shrike 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!

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

This comment has been minimized.

Show comment
Hide comment
@brucechase

brucechase Oct 27, 2017

brucechase commented Oct 27, 2017

Belorus added a commit to Belorus/EventStream that referenced this issue Nov 17, 2017

@rianjs

This comment has been minimized.

Show comment
Hide comment
@rianjs

rianjs Dec 6, 2017

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

rianjs commented Dec 6, 2017

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

@shoff

This comment has been minimized.

Show comment
Hide comment
@shoff

shoff 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.

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

This comment has been minimized.

Show comment
Hide comment
@304NotModified

304NotModified 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

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

This comment has been minimized.

Show comment
Hide comment
@jainaashish

jainaashish Apr 10, 2018

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.
Contributor

jainaashish commented Apr 10, 2018

@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

This comment has been minimized.

Show comment
Hide comment
@304NotModified

304NotModified Apr 10, 2018

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.

304NotModified commented Apr 10, 2018

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

This comment has been minimized.

Show comment
Hide comment
@flcdrg

flcdrg 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)

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