1

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
3
  • the SDKs should be available here: dotnet.microsoft.com/en-us/download/visual-studio-sdks not real sure about mono and the old .net4.x framework though... maybe re-install mono? Or use the newwer .NET6 which should be more cross-OS compatible. Commented Aug 11, 2023 at 22:06
  • @pcalkins That is were I tried to download it from as per my question, to no avail. I am not quite sure what you are suggesting here? Commented Aug 11, 2023 at 22:11
  • well the error mentions "v4.7.1" which is the old .net framework that's included in Windows OS. (that's older than .net-core v2 for instance... but you show your SDK is 7.0.4... that's .NET 7 (which used to be called "core", but they dropped the "core" after v3.x to avoid confusion with .net framework 4.x... it sounds like you need to target the .NET 7. Not familiar with VS Code, but also be sure the SDK is set for .NET7 (or use .NET6 if you want the LTS version...) Not sure if you need Mono for the "core" .net. Never developed .NET outside of Windows. Commented Aug 12, 2023 at 21:37

2 Answers 2

3

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

Sign up to request clarification or add additional context in comments.

Comments

0

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

1 Comment

I didn't try this. The solution shared in the accepted answer fixed it for me.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.