-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
VS2017 publish: project.assets.json doesn't have a target for .NETCoreApp,Version=v1.1 #1321
Comments
@rainersigwald did you figure this out? I'm seeing the same error trying to build a simple console app that targets net451 and netcoreapp1.1 |
@alexvy86 Not sure this would help, but I had the same issue when trying to build net40 project after building netstandard2.0 project, and both projects files are in the same folder. What resolves the issue for me is manually deleting the |
Thanks @bsivanov. I did try some variations of that but couldn't get it to work. To be sure I understood correctly: you have 2 separate project files, each one targeting a different framework, correct? For completeness sake in the discussion, in my case there's just one project which multi-targets net451 and netcoreapp1.1. |
@alexvy86 yes, you get me right, but apparently your problem is different. You can maybe try to split the multi-targeting project to two projects, just to check whether the issue is related to some problematic leftover in the project.assets.json. Or maybe try to change the order in |
I'm trying that as well (separate the projects) and ran into different errors that don't seem related. If I figure this out I'll post an update here. |
I have a .NET Standard 2.0 project and a .NET Framework 4.6.1 project in the same solution. When I try to build the 4.6.1 project, VS2017 shows the following error: Assets file 'C:\mySolution\dotnetFrameworkProject\obj\project.assets.json' doesn't have a target for '.NETFramework,Version=v4.6.1'. Ensure that restore has run and that you have included 'net461' in the TargetFrameworks for your project. in C:\Program Files\dotnet\sdk\2.0.0\Sdks\Microsoft.NET.Sdk\build\Microsoft.PackageDependencyResolution.targets 165 I tried deleting the project.assets.json file but the regenerated file didn't do me any good. I searched the project.assets.json file for the string Any ideas? |
Adding (hm this seems to be a fix for another flavour of the same problem :)) |
I encountered a similar error after updating my solution with multiple 1.1 projects to 2.0. I just deleted the bin and obj folders in each project and rebuilt. I no longer get the error. |
@altiss Thanks, this work for me too |
Deleting the obj and bin folders did not work for me. However I did manage to fix my issues using |
The issue cannot be reproduced after updating Visual Studio Professional 2017 to Version 15.3.2. @rainersigwald, this issue can be closed. Thanks. |
@kosa-gyula-77 I disagree, I just ran into this issue on 15.3.2, when trying to upgrade an application from netcoreapp1.1 to netcoreapp2.0. I had to delete the contents of the obj folder. |
What we've discovered now is that when we have .NET Core SDK 2.0 installed, we cannot build .NET Framework 4.6.1 projects with the new .csproj format. We keep getting the ...obj\project.assets.json... error |
@vullnetyy does this help? #1321 (comment) |
@patroza Do you mean the |
I get the same error. Also, when updating |
I 'm converting .net framework projects to the 'new' format and stumbled into this very problem. When It's an ugly solution of course but maybe it will help explain why this problem occurs?? (and how to solve this properly) ps. I have not tried this with a .Net Core project. |
Changing TargetFramework to TargetFrameworks worked for me for Core 2.0 Console app. |
I encounter this issue when publishing. Weird because I can publish successfully to my development environment, but publishing to production environment fails. Both environments are hosted in Azure as App Services and I am using Azure click-once deployment. I tried changing TargetFramework to TargetFrameworks, and deleted the project.assets.json file without success. |
I had the same as @Juslwk. I realised my publish profile was still targeting 1.1, even though 2.0 was showing as selected when I went into edit the profile, it showed 1.1 in the publish summary. So I re-selected 2.0 in the dropdown and it updated the summary to show 2.0 and it all worked fine |
This happened to me when I manually edited a csproj file to go from:
To:
I tried everything suggested here and the |
I got the same problem after I changed the target from net452 to net461, when I ran publish it complained the project was not compatible with net452 etc, even the target framework was set to net461 in the publish profile. BUT, I happened to find the TargetFramwork was still "net452" in the publish summary page, even in the "Setting" it was set to net 461. It was very wired. The solution then became very simple: Delete the publish profile, then create a new one with setting the target framework to that you want. Error is gone. |
@daveaglick I am running into a similar issue since I updated to Visual Studio 2017 15.4.1. It seems like reinstalling Visual Studio seems to fix this. I would like to find a solution to this since other machines may be affected by this. |
I ran into this today, in Visual Studio 15.4.4. I had edited the project file within VS (using right click / Edit) and changed the OutputType. The solution was to unload/reload the project in VS. It seemed VS did not honour the file change otherwise and instead gave the above error about frameworks. |
Just ran into this, read through the comments here, and was able to resolve. Simply did an unload and reload of the project as @memark mentioned. First compile didnt work but I suspect the restore was still running. Once it finished I rebuilt to success. Hope it helps and thanks to the commentators above. |
This issue seems to be related to how restore happens in visual studio after project changes. As such, I will move it to NuGet. |
The solution from @tunechr fixed my issue. |
Hmm, well, I don't have a |
Also, to be clear, I do use |
So... I wanted to follow up. I ended up pulling my |
Either update obj/project.assets.json to reference new framework or delete profile and re-create the profile. |
I was getting a similar error after updating my projects frameworks. I noticed in my publish profile file(Properties/PublishProfiles/*.pubxml) that the TargetFramework hadn't been updated to reflect the new framework. Changing manually in here or simply running through the configure option on my publish tab resolved the issue for me. |
@zeroish updating 'Properties/PublishProfiles/*.pubxml' worked for me. I was having the issue on windows, without resharper, VS 2017 15.7.4 |
@altiss solutions worked for me! |
I got this very same error on project.assets.json when I had converted a .Net 4.5 Class Library project to target multiple .Net Frameworks by manually updating the csproj file. After trying out almost all the solutions listed in this page, the fix that worked for me was to remove the below line from csproj which I had accidentally left: <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> |
I ran into this issue on a computer where I have not installed ReSharper. I first tried deleting the obj and bin folders and then re-publishing, but it wasn't until I upgraded VS to the latest version (15.9.4) that the issue went away. I did not try restarting VS prior to upgrading it, so I cannot say whether a restart of VS would've solved the issue for me. |
Same issue; editing .pubxml file manually was the only solution. VS 15.9.5; this happened when updating my project from .NET Core 2.1 to 2.2. Tried closing VS, deleting obj and bin folders, then re-opening, but that didn't fix it. Unlike an earlier comment, when I opened the Publish page, the "Target Framework" correctly showed "netcoreapp2.2", but when I opened the pubxml file, it was set to 2.1, not 2.2. Never had Resharper installed. I'm surprised a moderator kicked this over to NuGet. It's really the responsibility of NuGet to update Publish profiles when the project is restored with a newer version of .NET Core? |
In my case, I just had to rec-create my publish profile. |
Same issue on VS2019 Community and the solution of @dhieyson works for me. |
I am running Visual Studio 2019. Deleting the obj and bin folders seems to work just fine. No need to update any other settings. |
I am running Visual Studio 2019.
|
Ran into w/2019 - even though all targets were changed to 3.0 and bin and objs were removed. |
Add line below to the csproj file, beneath the <TargetFramework>netcoreapp3.0</TargetFramework> |
as @alexreich said, check your PublishProfiles files they can target other target Framework if you are doing a migration |
…0200305.1 (dotnet#1321) - Microsoft.AspNetCore.Analyzers - 5.0.0-preview.2.20155.1 - Microsoft.AspNetCore.Components.Analyzers - 5.0.0-preview.2.20155.1 - Microsoft.AspNetCore.Mvc.Api.Analyzers - 5.0.0-preview.2.20155.1 - Microsoft.AspNetCore.Mvc.Analyzers - 5.0.0-preview.2.20155.1
Still an issue in VS2019 16.6. Reopening the solution fixed it. |
I resolved this issue after trying absolutely everything in this thread (on the latest version of VS 2019 enterprise). It seems liked putting a project and solution in the same directory as the solution is no bueno. This is bad:
This is good:
|
Still an issue in VS2019 16.7.6 |
Having this issue in VS4Mac 8.7.9 (build 9) |
I suddenly got this issue even though it was working fine 5 minutes ago, VS Studio 8.7.9 (build 9) Mac OS |
Nothing works for me but after updating the VS 22, fixed my issue. Thanks all. :) |
Hi @bsivanov, you mentioned manually deleting the You must have had some issues when taking these projects to some DevOps pipeline and trying to build. Have you tweaked pre-build/post-build events to delete |
From @kosa-gyula-77 on June 8, 2017 14:27
Publishing the xunitCore1.0 project in the solution attached from Visual Studio 2017 fails with the following error:
Assets file 'C:\Users\xxx\Documents\Visual Studio 2017\Projects\xunitCore1.0\xunitCore1.0\obj\project.assets.json' doesn't have a target for '.NETCoreApp,Version=v1.1'. Ensure you have restored this project for TargetFramework='netcoreapp1.1' and RuntimeIdentifier=''.
Could you please help in identifying why I'm getting this error? xunitCore1.0 targets netcoreapp1.0.
xunitCore1.0.zip
Thanks.
Copied from original issue: dotnet/msbuild#2196
The text was updated successfully, but these errors were encountered: