Creating a new project using the "Avalonia Application" template in our extension fails with the following build error:
Assets file 'D:\temp\avalonia\AvaloniaApplication19\AvaloniaApplication19\obj\project.assets.json' doesn't have a target for '.NETFramework,Version=v4.6.1/win7-x86'. Ensure that restore has run and that you have included 'net461' in the TargetFrameworks for your project. You may also need to include 'win7-x86' in your project's RuntimeIdentifiers.
Removing the net461 target fixes it, but we need to work out what is wrong here. Adding the suggested RuntimeIdentifiers doesn't seem to fix it.
Actually it seems that adding the <RuntimeIdentifiers> does work, but not until after the bin and obj directories are deleted.
Nope, looking further into this, it seems that simply restarting VS causes it to build.
I can confirm that deleting the bin and obj, then restarting Visual Studio seems to be the only trick that works.
The following didn't work to resolve the issue in my environment:
Still the same error as reported.
I'm using:
Removing the net461 target resolves the problem. However, this would mean this project template may still have an issue.
Update: It doesn't matter which of the two target frameworks is remove or what sequence they are listed. As long as there is only one, it compiles. As soon as there are both, the reported error shows up.
Update 2: In my case this was related to an issue reported for ReSharper here. I updated VS to version 15.6.4 and now it compiles with both target frameworks in the project file.
Most helpful comment
The following didn't work to resolve the issue in my environment:
Still the same error as reported.
I'm using:
Removing the
net461target resolves the problem. However, this would mean this project template may still have an issue.Update: It doesn't matter which of the two target frameworks is remove or what sequence they are listed. As long as there is only one, it compiles. As soon as there are both, the reported error shows up.
Update 2: In my case this was related to an issue reported for ReSharper here. I updated VS to version 15.6.4 and now it compiles with both target frameworks in the project file.