Can someone please help me with the following error, it comes up when I try to build. Below is the message from the output window.
Failed to restore 'c:\directoryName\projectName\projectName.csproj' NuGet package restore failed. Please see the Error List window for detailed warnings and errors.
C:\Program Files\dotnet\sdk\6.0.302\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets(267,5): error NETSDK1005: Assets file 'C:\DirectoryName\ProjectName\obj\project.assets.json' doesn't have a target for 'netstandard2.1'. Ensure that restore has run and that you have included 'netstandard2.1' in the TargetFrameworks for your project.
I've tried the below but with no success:
- Right click on Solution and selected Restore Nuget packages
- Deleted the obj folder from then build it again
- Clean the solution and build again
- Uninstalled and reinstalled Visual Studio Professional 2022
- Cloned the repo
- unload and reload the project
- added this line in .csproj file
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
- Signed out of visual studio 2022, closed it and signed back in
- Checked I was running the latest nuget version
- did a
dotnet restore
from console - did msbuild -restore in console brings this error "MSB4181: The "RestoreTask" task returned false but did not log an error."
- Signed out of visual studio, closed it, and signed back in
- Signed with someone else's credentials
- Tools>Options>NuGet Package Manager>General>Clear All Nuget Cache
The .csproj file has everything in place:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="company.RepositoryFactory.Abstractions" Version="109.0.0.16" />
<PackageReference Include="company.UseCase.Abstractions" Version="96.0.0.5" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="5.0.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\company.ExternalprojectActivation.Messaging.Commands\company.ExternalprojectActivation.Messaging.Commands.csproj" />
</ItemGroup>
</Project>
Environment:
- Visual Studio 2022 Professional 17.2.6
- Nuget Package Manager 6.2.1
- Window Server 2016
Other developers in the team are able to build the above project without any errors.
Edit: I had updated the VS 2022 to 17.3.0. And now I am getting below
C:\Workspace\ProjectName\CompanyName.Project.UseCases.Abstractions\bin\Debug\netstandard2.1\CompanyName.Project.UseCases.Abstractions.dll' could not be found