3

I get this error when i try to build the app. I think somehow i need to do a .net restore but i dont know if it will work.. And i want to make it via code. The .csproj:

<Project Sdk="Microsoft.NET.Sdk">
  <Sdk Name="Microsoft.Build.CentralPackageVersions" Version="2.0.36" />
  <Import Project="..\..\..\..\MSBuild\root_configuration.props" />
  <PropertyGroup>
    <TargetFrameworks>net472</TargetFrameworks>
    <OutputPath>$(NUnitTestBinDir)\NunitTSAdapter</OutputPath>
    <SignAssembly>false</SignAssembly>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="NUnit" />
    <PackageReference Include="Microsoft.NET.Test.Sdk" />
    <PackageReference Include="NUnit3TestAdapter" />
  </ItemGroup>

  <ItemGroup>
    <ProjectReference Include="..\NUnitTestAdapter\NUnitTestAdapter.csproj" />
    <ProjectReference Include="..\NunitTSFeature\NunitTSFeature.csproj" />
  </ItemGroup>

  <ItemGroup>
    <Reference Include="WindowsBase" />
  </ItemGroup>
</Project>
  • Hi, any update about this issue? and let us know any progress about this issue. And we are willing to help you further. Besides, if you already have a solution, please share it here. – Mr Qian Jan 08 '21 at 09:44
  • no, i dont have any solution yet –  Jan 08 '21 at 17:42

3 Answers3

3

Just delete the obj folder from your project folder and then build again, you will not face the issue.

Update 1

Right-click on the Project on the Solution Explorer-->Properties-->Build Event

write these on the pre-build event command line:

del  obj\project.assets.json
dotnet restore

enter image description here

Mr Qian
  • 21,064
  • 1
  • 31
  • 41
  • and without deleting that? is there any other way? –  Jan 08 '21 at 17:42
  • You have to delete that file and then re-generate a new one by `dotnet restore` command. The previous solution which is provide by me is not an automated way, which makes you dissatisfied with that. So, I have an automated msbuild script function for you and you did not have to delete the file every time manually. – Mr Qian Jan 11 '21 at 09:54
  • I have updated my answer and you can check it:-) – Mr Qian Jan 11 '21 at 09:54
  • this way works, but i am still looking for a long time way to work, and for every one –  Jan 13 '21 at 12:33
1

I deleted both bin and obj folder within src/common, src/domain, and src/ folders and then opened command prompt and changed to solution directory and run below command

dotnet restore
Sky scream
  • 35
  • 5
0

i spent one day for this error. I tried a lot of ways but still not successfull, such as:

  • reopen Visual studio
  • delete /obj, /bin
  • run dotnet clean/restore, reinstall workload...

Finally, i increased "Minimum Target Android Framework" in "Android targets" .csproj file, then it built OK. Maybe there is something wrong with .csproj file.

Hewit HN
  • 1
  • 1