1

Whenever I try to build the project I receive the following error.

enter image description here

I checked .net sdk installation location, and it also looks fine.

enter image description hereThe build setting is set to .net 7. Here is the file .csproj

 <Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>net7.0</TargetFramework>
    <Nullable>enable</Nullable>
    <ImplicitUsings>enable</ImplicitUsings>
    <LangVersion>preview</LangVersion>
  </PropertyGroup>

  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>
  <ItemGroup>
    <None Remove="docfx.console" />
    <None Remove="Microsoft.NETCore.Platforms" />
    <None Remove="NETStandard.Library" />
    <None Remove="Microsoft.AspNetCore.Http.Features" />
  </ItemGroup>
  <ItemGroup>
    <PackageReference Include="docfx.console" Version="2.59.4">
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
      <PrivateAssets>all</PrivateAssets>
    </PackageReference>
  </ItemGroup>
</Project>

I have uninstalled and installed the visual studio and the sdks. Also, removed the sdks and tried with brew donet sdk installation but it has not given any result because the visual failed to detect the brew installed dotnet sdk. Tried with other older versions of SDKs but the error remains same as Visual studio fails to detect the framework.

I have tried several solutions offered on StackOverflow and other platforms but none seem to be working. I am not sure if it is a bug in visual studio for macOS.

bhaskar das
  • 175
  • 4
  • 20
  • ".NETFramework,Version=v7.0" is wrong, that should be ".NETCoreApp,Version=v7.0". Bad project file, perhaps, the TargetFramework element should be "net7.0". Next guess is that msbuild is outdated and can't translate ".net7.0" to the correct tfm, the VS version must be at least 17.4 – Hans Passant Nov 15 '22 at 20:01
  • I am using version 17.4 only. I have also raised the issue with Microsoft developer forum https://developercommunity.visualstudio.com/t/Error-MSB3971:-The-reference-assemblies-/10201837 – bhaskar das Nov 16 '22 at 14:28
  • 1
    Do you have other projects in the solution? If you do I would check the Solution Properties - Build - General, and uncheck 'Build with MSBuild on Mono'. – Matt Ward Nov 17 '22 at 18:43
  • 1
    Ah, I see you tried that on the developer community site. The error with 'docfx.console' is because it does not support being run with mono. Its docfx.console.targets file tries to run the docfx.exe directly, which will not work. It would need to prefix this with Mono. The docfx NuGet package looks Windows specific. – Matt Ward Nov 17 '22 at 18:46
  • @MattWard Thanks for the explanation. Indeed I didn't see it that docfx.console doesn't support running with Mono. Thanks once again. That provides the answer. so I have to think of alternatives then for creating a docFX project. – bhaskar das Nov 19 '22 at 07:10
  • 1
    There are tricks you can use to get .exe files to automatically run with mono but these only work from the terminal, not when a program, such as msbuild, runs the executable - https://unix.stackexchange.com/questions/47320/how-to-set-bash-to-run-exe-with-mono – Matt Ward Nov 19 '22 at 12:16
  • 1
    For docfx, you could probably add it as a package reference but set ExcludeAssets="all" then setup your own msbuild target/task that runs docfx.exe with mono. Assuming docfx.exe works OK with mono. – Matt Ward Nov 19 '22 at 12:18

0 Answers0