ASP.NET Core Application (.NET Framework) for Windows x64 only error in project.assets.json

天大地大妈咪最大 提交于 2019-11-29 09:09:09
Adam

For some reason <TargetFramework> in my .csproj file was singular. I added an "s" and it became "TargetFrameworks", which worked:

  <PropertyGroup>
    <TargetFrameworks>net462</TargetFrameworks>
    <RuntimeIdentifier>win7-x64</RuntimeIdentifier>
  </PropertyGroup>

I didn't change my TargetFramework, I ran in the Package Manager Console the command:

dotnet restore

And it worked! (I'm using VS2017 and I'm doing a .net core application pointing to .net framework)

I had manually changed mine from x86 to x64. In this case, just restoring the packages from Visual Studio would not work but closing Visual Studio, deleting the project.assets.json, re-starting Visual Studio and re-building the project worked for me. I left <TargetFramework> singular.

Command line nuget restore ... may also have worked.

I had this issue when trying to publish a dotnetcore console application to a local folder after upgrading it to version 2.0.

After trying all the deleting folders and dotnet restore and making sure all settings in Application and Build were 2_0 to no avail. 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.

I have a .net core application pointing to .net framework 4.6.1 in VS2017 which I tried to publish. I changed my platform target from x86 to x64 and started to get this error when I tried to publish again but I didn't have any problems to build. I just opened publish profile settings and everything looked normal (target runtime was win7-x64) but that was enough for my publish to start working properly.

For some reason <RuntimeIdentifier> in my .csproj file was missing. Adding it resolved this issue for me:

<PropertyGroup>
  <TargetFramework>net472</TargetFramework>  
  <RuntimeIdentifier>win-x64</RuntimeIdentifier>      
  <Platforms>AnyCPU;x64</Platforms>
  <LangVersion>7.3</LangVersion>
</PropertyGroup>

Check the actual publishing profile file of the Publish you are trying to run. In our case, we have a set of projects that have to be shared between Core and regular asp.net, so we target Core 1.1 and set the runtime version to 4.6.1. After running through all of the projects and updating them to target version 4.7, I started getting this error on publish (the actual builds worked fine, as did localhost debugging, it was the publish that was jacked).

Checking the actual "widgets - Web Deploy.pubxml" file, I found this at the bottom:

    <_DestinationType>AzureWebSite</_DestinationType>
    <TargetFramework>net461</TargetFramework>
    <RuntimeIdentifier>win7-x64</RuntimeIdentifier>
  </PropertyGroup>
</Project>

As others on this thread have mentioned, simply opening up the property sheet of the publishing profile will show you, in my case, that the framework was targeted to 4.7 (which was accurate per the projects involved but did not reflect the actual value in the file)... I did still need to click the Save button to get the underlying .pubxml file to actually be updated with the correct value. You can probably edit that file manually too, if you feel so inclined.

This one drove me nuts. :)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!