skip to Main Content

Problem

The time has come again for VSCode to update something related to C# (I suspect the culprit is the C# for VSCode extension, which did update itself just before this problem appeared, but I can’t be sure). And as so often is the case (I am thinking back to when it used to be the OmniSharp extension causing problems, which is now part of VSCode), new errors appear in the Output window, disrupting Unity development on macOS.

This time around, the warning is as follows:

Warning while loading ../Unity/MyGame/Assembly-CSharp.csproj: The reference assemblies for .NETFramework,Version=v4.7.1 were not found. To resolve this, install the Developer Pack (SDK/Targeting Pack) for this framework version or retarget your application. You can download .NET Framework Developer Packs at https://aka.ms/msbuild/developerpacks

NB: This also applies to other .csproj files. The warnings appear when VSCode is first opened, and then again whenever a file is saved.

Attempts

1.) The warning suggests to "install the Developer Pack (SDK/Targeting Pack) for this framework version" and points to https://aka.ms/msbuild/developerpacks.

  • If I follow the link labelled "Developer Pack", it downloads the .NET Framework 4.7.1 Developer Pack Offline Installer. I get a file called ndp471-devpack-enu.exe. Opening this file leads to an extraction process resulting in 33 files, one labelled 0, and the rest labelled u0 to u31. There is nothing I can install, and no explanation for what to do with these files.
  • If I instead follow the link labelled "Runtime", it downloads the .NET Framework 4.7.1 Web Installer. I get a file called ndp471-kb4033344-web.exe. Opening this file leads to an error message stating "The contents of "ndp471-kb4033344-web.exe" cannot be extracted with The Unarchiver."

2.) The other part of the warning suggests to "retarget your application". But I don’t know how to do that, or if that is even the right approach here.

  • Update: This answer suggests that Unity forces a target framework value of "net471", so it is not possible to retarget the application in case of Unity.

3.) Based on prior experience, I used "Regenerate project files" under Unity > Preferences > External Tools. But this had no effect here.

4.) Based on prior experience, I installed all the latest updates for Visual Studio 2019 For Mac. But this had no effect here.

5.) I installed Visual Studio 2022 For Mac (latest version). But this had no effect.

Versions and settings

Versions:

  • macOS 12.6.7
  • Unity: 2022.2.1f1
  • C# for VSCode extension: v2.0.357

settings.json:

  • "omnisharp.monoPath": "/Library/Frameworks/Mono.framework/Versions/6.12.0",
  • "omnisharp.useModernNet": false,

Other info:

  • Dotnet path: /Users/Ben/Library/Application Support/Code/User/globalStorage/ms-dotnettools.vscode-dotnet-runtime/.dotnet/7.0.10/dotnet
  • Output of dotnet --info:
    • .NET SDK: Version: 7.0.400
    • .NET SDKs installed: A long list including various 2. ,3. 5. and 7. versions, but notably excluding any 4. versions.
    • .NET runtimes installed: Same note as above.
  • Output of mono --version: Mono JIT compiler version 6.12.0.182

2

Answers


  1. Had the same problem on Linux here! (just fixed it a few minutes ago)
    The problem indeed comes with the new version of the vscode c# extension, which changes the intellisense server.

    I first followed this guide, to install an older verison: https://github.com/dotnet/vscode-csharp/issues/3351
    This did fix it! However, I was getting a lot of server related pop-up error messages.

    The github page explains how to enable OmniSharp on the latest verison:
    https://github.com/dotnet/vscode-csharp#how-to-use-omnisharp
    (the "how to enable omnisharp" section)

    Basically, you have to dotnet.server.useOmnisharp to true.

    *It does not work with c# dev kit extension active

    Login or Signup to reply.
  2. I’ve gotten the same problem on macOS since yesterday. After I did the following steps, the warning went away.

    1. Install the Unity extension
      enter image description here
    2. Follow the instructions on the extension page and update the package Visual Studio Editor 2.0.20

    Note: the Visual Studio Code Editor package is a legacy package from Unity that is not maintained anymore.

    1. Regenerate project files

    enter image description here

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search