After I upgrade my project files to new project file format, my executable client project (.exe
) throw the error when I compile it with msbuild
:
error NETSDK1047: Assets file obj\project.assets.json doesn't have a target ".NETFramework,Version=v4.8/win7-x86". Make sure that the restore has been performed and that you have included "net48" in the TargetFrameworks for your project. You may also have to include "win7-x86" in the RuntimeIdentifiers of your project.
I upgrade a lot of projects but only the executable client project make some trouble, the rest works fine.
Old .vbproj
Format (header only):
The format I used before look like:
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{1187BEA1-xxxx-43CF-xxxx-0C142F0A16FC}</ProjectGuid>
<OutputType>WinExe</OutputType>
<MyType>WindowsForms</MyType>
<RootNamespace>MyNamespace</RootNamespace>
<AssemblyName>MyAssemblyName</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<OptionExplicit>On</OptionExplicit>
<OptionCompare>Binary</OptionCompare>
<OptionStrict>On</OptionStrict>
<OptionInfer>On</OptionInfer>
<ApplicationIcon>MyIcon.ico</ApplicationIcon>
<RestorePackages>true</RestorePackages>
</PropertyGroup>
New .vbproj
Format (header only):
The format I upgrade to looks like:
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
<PropertyGroup>
<RootNamespace>MyRootNamespace</RootNamespace>
<AssemblyName>MyAssemblyName</AssemblyName>
<Deterministic>false</Deterministic>
<TargetFramework>net48</TargetFramework>
<OutputPath>$(SolutionDir)bin\$(Configuration)\</OutputPath>
<OutputType>WinExe</OutputType>
<ApplicationIcon>MyIcon.ico</ApplicationIcon>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<OptionStrict>On</OptionStrict>
<StartupObject>Program</StartupObject>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<UseWindowsForms>true</UseWindowsForms>
</PropertyGroup>
What I Try?
Like the exception suggest, I add
<RuntimeIdentifier>win7-x86</RuntimeIdentifier>
to my executable client project. I have know idea why the compiler expectwin7-x86
here. I am working on awin10
machine. I performgt clean -xfd
to get rid of theobj
folders, but nothing changed, same exception.I use
dotnet restore my.sln
instead ofnuget restore
More Information:
I am not really sure whether the
<StartupObject>Program</StartupObject>
combined with<OutputType>WinExe</OutputType>
is enough for a executable client project. Is that state of the art?Another weird thing is, that the first compilings works totally fine. After a few times the mentioned exception occurs. The exception can also be solved by a full machine reboot, but I can't reboot my machine after each compile.
The exception (
NETSDK1047
) get thrown by theMicrosoft.PackageDependencyResolution.targets
(full path:C:\Program Files\dotnet\sdk\3.1.401\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets(241,5)
)I restore my solution dependencies and packages with
nuget restore my.sln
So what can I do here? :(