_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:UsersxxxDocumentsVisual Studio 2017ProjectsxunitCore1.0xunitCore1.0objproject.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.
Thanks.
_Copied from original issue: Microsoft/msbuild#2196_
@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 \obj\project.assets.json
file, which tends to break the build for the net40 project, if present, with the following error:
_Your project is not referencing the ".NETFramework,Version=v4.0,Profile=Client" framework. Add a reference to ".NETFramework,Version=v4.0,Profile=Client" in the "frameworks" section of your project.json, and then re-run NuGet restore._
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 <TargetFrameworks>
, if it matters at all?
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:mySolutiondotnetFrameworkProjectobjproject.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 Filesdotnetsdk2.0.0SdksMicrosoft.NET.SdkbuildMicrosoft.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 TargetFrameworks
(case insensitive) and only found a key called originalTargetFramework
.
Any ideas?
Adding <RuntimeIdentifier>win7-x64</RuntimeIdentifier>
to the csproj, beneath the <TargetFramework>net462</TargetFramework>
seems to work.
(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
dotnet restore mysolution.sln
after getting the latest versions of Visual Studio 2017 and .NET Core 2
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 ...objproject.assets.json... error
@vullnetyy does this help? https://github.com/dotnet/sdk/issues/1321#issuecomment-323606946
@patroza Do you mean the <RuntimeIdentifier>win7-x64</RuntimeIdentifier>
? No. We did try moving to 4.6.2 and placing it beneath TargetFramework
and it didn't work anyway. Thanks for trying.
I get the same error. Also, when updating <targetFrameworks>
by changing targets the project.assets.json
doesn't seem to sync the changes.
I 'm converting .net framework projects to the 'new' format and stumbled into this very problem. When
I add <TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
to the .csproj then my project compiles and runs as expected.
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.
https://stackoverflow.com/questions/42842443/asp-net-core-application-net-framework-for-windows-x64-only-error-in-project
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.
In the end, the way I fix it was, I modified the Development publish profile and changed my connection details to point to the production. After that it publishes successfully.
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:
<TargetFrameworks>netstandard1.6</TargetFrameworks>
To:
<TargetFrameworks>net46;netstandard1.6</TargetFrameworks>
I tried everything suggested here and the project.assets.json
file just kept coming back the same. It wasn't until I closed Visual Studio, deleted the obj
folder, and reopened Visual Studio that the restore created a new project.assets.json
file with the targeting changes. I suspect the NuGet process in VS must be caching the packages somewhere in memory and won't regenerate the file just for targets changes.
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.
I have a core 2.0 library project. I edited the csproj file to add .net45 to targetframeworks. Upon compiling I was getting the Assets file error mentioned above. Tried deleting bin and obj directories and recompiling. This did not work.
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.
This issue was moved to NuGet/Home#6482
This conversation has gone a lot of different directions, so forgive me if I miss a scenario.
I've tested out 2 different scenarios, with the latest 15.6 P2 build.
1) Adding a new target framework in VS.
Expected: Restore happens, targets in the project assets json are updated.
Actual: Restore happens, the targets in the project.assets.json are not updated, however the package spec is updated.
This is definitely a bug.
Hint for later investigation, the originalTargetFrameworks are out of sync with the targetframeworkinformation.
2) Changing the output type from Exe to Library etc.
Note that "NuGet" does not care directly what the output type is, the difference here is that some of the implied dependencies change in the netcore case when the output is changed. Other things such as a RuntimeIdentifiers are specified in the Exe case as well, which affects restore.
Expected: Restore happens, targets in the project assets json are updated.
Actual: Restore happens, targets in the project assets json are updated.
No repro on this scenario.
Update:
This seems like it's a nomination issue.
BEGIN Nominate Restore for C:\Users\nikolev.REDMOND\Source\Repos\ConsoleApp21\ConsoleApp21\ConsoleApp21.csproj
BaseIntermediatePath: obj\
OriginalTargetFrameworks: netcoreapp2.0; net461
Target Frameworks (2)
net45
Project References
Package References
Target Framework Properties -- (RestoreAdditionalProjectFallbackFolders:;C:\Program Files\dotnet\sdk\2.1.4\Sdks\Microsoft.NET.Sdk\build\..\..\..\..\NuGetFallbackFolder | RestorePackagesPath: | MSBuildProjectDirectory:C:\Users\nikolev.REDMOND\Source\Repos\ConsoleApp21\ConsoleApp21 | RestoreAdditionalProjectSources: | PackageId:ConsoleApp21 | RuntimeIdentifier: | NoWarn:1701;1702;1705 | RestoreAdditionalProjectFallbackFoldersExcludes: | TargetFrameworkIdentifier:.NETFramework | VersionSuffix: | DotnetCliToolTargetFramework:netcoreapp2.0 | VersionPrefix:1.0.0 | BaseIntermediateOutputPath:obj\ | Version:1.0.0 | RestoreFallbackFolders: | MSBuildProjectFile:ConsoleApp21.csproj | TargetFrameworkMoniker:.NETFramework,Version=v4.5 | EmitAssetsLogMessages:true | TargetFramework:net45 | PackageTargetFallback: | TreatWarningsAsErrors:false | TargetFrameworkProfile: | RestoreSources: | TargetFrameworks:netcoreapp2.0; net461 | TargetFrameworkVersion:v4.5 | RuntimeIdentifiers: | PackageVersion:1.0.0 | WarningsAsErrors:NU1605 | AssetTargetFallback:)
netcoreapp2.0
Project References
Package References
Microsoft.NETCore.App -- (Description: | RuntimeIdentifier: | NoWarn: | OriginalItemSpec: | FrameworkName: | Version:2.0 | Visible: | TargetFramework: | IncludeAssets: | PrivateAssets:All | ExcludeAssets: | IsImplicitlyDefined:true | FrameworkVersion: | Name: | Type: | Path:)
Target Framework Properties -- (RestoreAdditionalProjectFallbackFolders:;C:\Program Files\dotnet\sdk\2.1.4\Sdks\Microsoft.NET.Sdk\build\..\..\..\..\NuGetFallbackFolder | RestorePackagesPath: | MSBuildProjectDirectory:C:\Users\nikolev.REDMOND\Source\Repos\ConsoleApp21\ConsoleApp21 | RestoreAdditionalProjectSources: | PackageId:ConsoleApp21 | RuntimeIdentifier: | NoWarn:1701;1702;1705 | RestoreAdditionalProjectFallbackFoldersExcludes: | TargetFrameworkIdentifier:.NETCoreApp | VersionSuffix: | DotnetCliToolTargetFramework:netcoreapp2.0 | VersionPrefix:1.0.0 | BaseIntermediateOutputPath:obj\ | Version:1.0.0 | RestoreFallbackFolders: | MSBuildProjectFile:ConsoleApp21.csproj | TargetFrameworkMoniker:.NETCoreApp,Version=v2.0 | EmitAssetsLogMessages:true | TargetFramework:netcoreapp2.0 | PackageTargetFallback: | TreatWarningsAsErrors:false | TargetFrameworkProfile: | RestoreSources: | TargetFrameworks:netcoreapp2.0; net461 | TargetFrameworkVersion:v2.0 | RuntimeIdentifiers: | PackageVersion:1.0.0 | WarningsAsErrors:NU1605 | AssetTargetFallback:;net461)
Tool References
------------------------------------------
COMPLETED Nominate Restore for C:\Users\nikolev.REDMOND\Source\Repos\ConsoleApp21\ConsoleApp21\ConsoleApp21.csproj
Note that OrignalTargetFrameworks is "net461".
Target Frameworks is net45.
The action that I did was changing net45 to net461.
//cc
@natidea @emgarten
If this is a nomination problem, it belongs in dotnet/project-system, not at the SDK.
@natidea or @Pilchie can you confirm?
I've created an issue in Project to track this: https://github.com/dotnet/project-system/issues/3182
May also be related to https://github.com/dotnet/project-system/issues/2657
I removed the following configuration in the csproj file:
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<PlatformTarget>AnyCPU</PlatformTarget>
</PropertyGroup>
Along with
<RuntimeIdentifier>%Platform%</RuntimeIdentifier>
I am passing the Platform setting when calling MSBuild with: /p:Platform="Any CPU"
Making these changes helps me build in VS as well as my msbuild scripts
In my case showed this error when publishing:
C:Program Filesdotnetsdk2.1.102SdksMicrosoft.NET.SdkbuildMicrosoft.PackageDependencyResolution.targets(167,5): Error : Assets file 'C:Myprojectobjproject.assets.json' doesn't have a target for '.NETCoreApp,Version=v2.0'. Ensure that restore has run and that you have included 'netcoreapp2.0' in the TargetFrameworks for your project.
I tryed every restore options but not function.
To solution my problem i deleted folder "C:Program Filesdotnetsdk2.1.102". After that i published again with success
@dhieyson this fixed it for me, too. Had this problem after upgrading my VS2017 this morning to newest version.
Also, the solution posted by @dhieyson worked for me. Nothing else posted in this thread. The problem has occurred after the installation of the newest version of VS.
I had the same problem after updating my VS today!
Solution posted by @dhieyson solved this issue for me. Thanks!
@dhieyson 's solution solved my problem too. dotnet sdk 2.1.102 seems to be the problem.
To be clear, the latest version at the time of writing is VS2017 15.6.3.
I'm having the same issue and the workaround posted by @dhieyson also worked for me.
Same issue here as @RomeDev describes. 15.6.3. Deleting the "C:Program Filesdotnetsdk2.1.102" also worked for me. I had to do a repair install after this update as well, as the Package Manager Console stopped working (displayed an exception)
+1, this is a substantial productivity impact
+1, same issue here. Removing sdk 2.1.102 folder in "C:Program Filesdotnetsdk" did fix it...
I had the same problem after updating my VS today, solution posted by @dhieyson solved this issue for me also. Thanks.
Suspect there will be another update to VS very shortly.
+1, we also ran into this issue after upgrading to 15.6.3, in our case with target framework uap10.0.
I had the same problem after updating VS to 15.6.3
+1, Same problem after updating VS to 15.6.3 both on windows 10 x64 and windows server 2016 x64 (Resharper enabled on both). Removing sdk 2.1.102 as posted by @dhieyson also solved for me, however I had to download manually the sdk 2.1.101 and repair it due to colateral damage of my other attempts to solve the issue.
MSFT suggested I disable ReSharper, and indeed, that works around the problem... but coding without ReSharper... no thanks.
I'm curious if anyone on this thread is seeing the issue but does not have ReSharper installed and enabled.
I was able to go back to Visual Studio 15.5.7 following the instructions here: https://docs.microsoft.com/en-us/visualstudio/productinfo/installing-an-earlier-release-of-vs2017
That fixed the problem for me, even after reinstalling ReSharper.
@mjolka Thank you for that link.
Had same problem when ReSharper is enabled.
The solution posted by @dhieyson worked for me (https://github.com/dotnet/sdk/issues/1321#issuecomment-374706295).
I removed "C:Program Filesdotnetsdk2.1.102" and all is Ok. But what is the source of problem?
I found report on MS Developer Community forum https://developercommunity.visualstudio.com/content/problem/218434/after-updating-to-the-new-version-my-corenet-proje.html
Our initial investigation show that this only repros if ReSharper is installed. Disabling ReSharper extension seems to fix this issue. We are still investigation the root cause. We hope to release an update with the fix soon. Thanks for your patience.
I'm the same problem.
Probably caused by the installation of the ReSharper plug-in, my solution is to use ReSharper build, set ReSharper build: ReSharper-> Tools -> Build & Run. This solves my problem, may wish you also try.
Edit: VS15.6.4 have been repaired.
See #2068 for info about problem with 2.1.102 SDK
I'm having this problem but do not have ReSharper enabled (it is installed but suspended).
@scottfavre I found that suspending wasn't enough; I had to disable it through Tools -> Extensions and Updates.
@hughbiquitous
You are right, disabling ReSharper is the solution.
I have an asp .netcore 2.0 project that used to publish fine. Today I only updated some minor string in my project. It builds and runs fine but when trying to publish it to azure I got:
"Assets file 'C:xxxobjproject.assets.json' doesn't have a target for '.NETCoreApp,Version=v2.0'. Ensure that restore has run and that you have included 'netcoreapp2.0' in the TargetFrameworks for your project."
After googling for hours and only after disabling Resharper like hughbiquitous suggested I could finally publish again.
If I remember well I could publish in the past with ReSharper enabled and I did not update ReSharper that I know off. The only thing I did was updating Visual Studio to version 15.6.3.
This solution worked for me, is just adding an s in all
https://stackoverflow.com/a/42855070/819153
how is this related to that?
This issue should be fixed in the 15.6.4 update that was published this morning.
15.6.4 fixed it for me, thanks @Pilchie
@Pilchie I can also confirm that 15.6.4 published the project without errors. It seems that the new dotenet sdk 2.1.103 installwd with the update solved the problem.
The problem is also fixed in ReSharper 2017.3.5, everything works with all combinations of Visual Studio and .NET Core SDK.
You can find more technical details in the official blog post: https://blog.jetbrains.com/dotnet/2018/03/23/build-failures-visual-studio-15-6-3-resharper-ultimate-2017-3-5-rescue/
Everything has been fixed on this version: vs15.6.4
----------MS -----------
Release Date: March 22, 2018 - Visual Studio 2017 version 15.6.4
Issues Fixed in this Release
These are the customer-reported issues addressed in this release:
Assets File 'c:xxxxxxobjproject.assets.json' doesn't have a target for '.NETStandard,Version=v2.0'.
VS2017 fails to persist settings on first launch if there is another VS instance running from another user.
Android LLVM libc++ static library STL broken with VS15.6.0.
Unit tests no longer sorted alphabetically.
The solution from @dhieyson works for me!
For me, recreating a .sln fixed the problem.
My solution was:
Change publish profile, this tag in particular:
<TargetFramework>netcoreapp2.0</TargetFramework>
From 1.0 to 2.0.
For me, opening the 'Publish' Page, then open the 'Configure' dialog, then resaved. It probably just sorted the tags
The solution from @tunechr fixed my issue.
Hmm, well, I don't have a C:\Program Files\dotnet\sdk\2.1.102
, so I don't know. Even after invoking the nuget.exe
process with restore
options, successfully I might add, the assets file lands where expected, I STILL get the error.
Also, to be clear, I do use R#
, but I do not have it enabled for build and run features.
So... I wanted to follow up. I ended up pulling my C:\Program Files\dotnet\sdk
folders aside, both 2.1.200
and 2.1.201
, and the programmatic invocation succeeded. From there I should be able to verify before and after states that I expect with my custom MSBuild tasks.
Either update obj/project.assets.json to reference new framework or delete profile and re-create the profile.
Assumptions:
-Upgraded project from netcore2.0 to 2.1
-The error encountered when you try to publish using an existing 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:
I'm curious if anyone on this thread is seeing the issue but _does not_ have ReSharper installed and enabled.
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.
That ensured everything was in sync.
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.
1) Delete the obj and bin folders
2) Add line below to the csproj file, beneath the <TargetFramework>netcoreapp3.0</TargetFramework>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
3) Restart Visual Studio
4) Publish project
Ran into w/2019 - even though all targets were changed to 3.0 and bin and objs were removed.
The Publish profile was not changed and had to be manually modified: altering the pubxml file fixed the issue.
Add line below to the csproj file, beneath the
as @alexreich said, check your PublishProfiles files they can target other target Framework if you are doing a migration
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.
For example:
This is bad:
- Solution.sln
- Project.csproj
- Startup.cs
- Program.cs
- /OtherProject
- OtherProject.csproj
...
...
This is good:
- Solution.sln
- /Project
- Project.csproj
- Startup.cs
- Program.cs
- /OtherProject
- OtherProject.csproj
...
...
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
Most helpful comment
Adding
<RuntimeIdentifier>win7-x64</RuntimeIdentifier>
to the csproj, beneath the<TargetFramework>net462</TargetFramework>
seems to work.(hm this seems to be a fix for another flavour of the same problem :))