.NET core SDK cannot be located vscode unity c# - c#

my problem
I am on windows 10 I tried reinstalling .net multiple times and re installed vscode i am really despreate for soloutions now

Probably an issue with your .csproj. If you are on windows I cannot recommend enough for you to switch to Visual Studio. Everything is integrated, and trust me. Visual studio code will run into these types of problems every 5 minutes, where visual studio will not. If you are using unity I remember having to change “targetting packet” in the .csproj to 4.7.1 every time I loaded visual studio code. If you are not using unity, make sure you have run “dotnet new console” and “dotnet restore”.

Check your project file and take a look what kind of .net version is used there. Then look for that version in microsoft .net download page

Related

Creating an ASP.NET Core project

I want to create an Asp.net Core project with Visual Studio 2017 Community but the Solutions explorer says that I have (0 projects).
I tried selecting an empty project, web application, web application (Model-View-Controller) but the Solution explorer still displays (0 projects).
When I go-to Debug I see the "Attach to Process" option. There is no option to start of course since I have no projects.
What could be the issue?
Have you installed everything correctly? To verify this, open a normal cmd and just type 'dotnet'
Only if the command runs, printing out information about how to use dotnet, you're good to go.
Have you installed the correct .NET SDK? What version of it? Make sure the version is compatible with the version of visual studio you have installed.
Follow this link for step by step setup instructions:
https://www.c-sharpcorner.com/article/getting-started-with-net-core-on-visual-studio-2017/
This could be the same problem, but I had the same issue during College once but this time I had the support for the web components, so I went back to the installation and repaired it. It downloaded the missing files and it worked again and it took a while.
Let me know if that works or not.

How to get intellisense in Visual Studio Code for Unity functions names?

I am following a tutorial about Unity and I see that the instructor has intellisense when writes the method's name.
However I have only intellisense with classes and variables, I mean Unity classes like Rigidbody and my own variables.
I have also read:
Autocompletion not working in Visual studio
How to enable intellisense in Visual Studio 2017 for Unity
Old question, but I had the same problem just recently.
There must have been an issue in your Assembly-CSharp.csproj or project-name.sln files. Most likely to be the .csproj file. If you take a look at it, you will see various references to .dll files.
You can tell Unity (my version: v2019.2.20f1) to create these for you by enabling Edit > Preferences > Generate all .csproj files.
1. Delete both files.
2. Enable .csproj file generation.
3. Double click on a script in Unity.
This fixed my issue.
I would really like to clear things up a bit for everyone trying to get Intellisense working with Visual Studio Code.
First of all I am writing this for Unity 2019.4.14 (edit: also for 2020.3 and 2021.3).
These are the things you MUST do for this to work:
You need Visual Studio Code (duh)
You need .NET SDK. I don't think it matters which version, latest is the best I guess. Make sure you install the SDK, not the runtime.
Check if you have .NET SDK installed by typing dotnet in the VSCode terminal.
You also need The .NET Framework Dev Pack because otherwise VSCode is going to be throwing this error:
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.
In VSCode search for the 'C# for Visual Studio Code' extension and install it
In Unity go to Package Manager and install Visual Studio Code Editor. This will enable Unity to generate proper project files for VSCode. (might be already installed)
In Unity go to Edit -> Preferences -> External Tools and choose VSCode from the dropdown (could be listed as code.cmd) and after you choose it tick all the checkboxes you want in the Generate .csproj files for section. I checked Embedded Packages, Local Packages, and Packages from unknown sources. Click 'Regenerate project files'
Open any C# file from Unity and you should be good to go. (you might need to restart VSCode after regenerating project files in order for this to work)
Now, what about Unity Code Snippets and Debugger for Unity extensions? Well these are useful helper extensions but they have nothing to do with Intellisense. The first is for quickly typing common Unity patterns and the second is for showing Unity Debug warnings and errors as you type instead of saving and going back to Unity and reading the console.
Hope this was of any help.
p.s.
One more note: Visual Studio Code depends on the solution files we generate through Unity for Intellisense to work. This is important because you have to add the entire project folder to VSCode workspace and not just Assets folder or your Scripts folders. If you add only the Assets folder to VSCode it won't be aware of those solution (.sln) files. If you open scripts through Unity it will probably work regardless.
Although the answer by Alex Myers is helps, its not 100% right. Unity Snippets does give you some snippets, and the illusion of typeahead, it's not actually intellisense.
For true intellisense you need to:
install dotnet on your system (https://code.visualstudio.com/docs/languages/dotnet) and,
install the dotnet extension for VSCode (https://marketplace.visualstudio.com/items?itemName=ms-vscode.csharp)
More information can be found here: https://code.visualstudio.com/docs/languages/dotnet
You can test you have dotnet installed by typing dotnet into the terminal within VSCode.
Note In the image below how I get a full method signature, reference counts, and the yellow hint globe. These are only available when using dotnet + extension (and not available when using the snippets)
Note: my solution does not solve intellisense to function names, but this was the first question that come in fixing intellisense more generally in VSCode.
I needed to update the VSCode package in unity.
In Unity, click Window, then Package Manager, then look for Visual Studio Code Editor. Expand it by pressing triangle, and upgrade to the latest version (for me, it was 1.2.0. I restarted VSCode and it worked.
v1.1.4 had a bug that caused this problem, and was not fixed for about 3 months. It is still the default package installed with a new default project, so you have to change this package version to 1.2.0 in every new project, until they update it.
Check out the guide for Unity Development with VS Code. They recommend a few extensions:
Unity Snippets
Debugger for Unity
Unity Tools
I believe the Unity Snippets extension is what you are looking for.
For anyone having the same problem on a Mac, try setting this value in your .vscode/settings.json (or in the user settings instead of the workspace settings)
"omnisharp.useGlobalMono": "always"
For me just in Unity, Edit/Preferences/External Script Editor, and changed it to My_Install_Location\Microsoft VS Code\Code.exe (maybe hit Regenerate Project Files)
Sorry, I don't have good English, but I'll show you what worked for me.
I opened the C # script in Visual Studio Code and looked for the Assembly-CSharp.csproj file, then, on line 16, I changed the following:
<TargetFrameworkVersion> v4.5 </TargetFrameworkVersion>
For:
<TargetFrameworkVersion> v4.5.1 </TargetFrameworkVersion>
This solved the Intellisense issue.
Intellisense is a pure workflow of .Net Environment. So, you need to have .Net 'Developer pack' (not Runtime) installed on your system as it installs all three necessary components below:
.Net framework
.Net Target pack
.net SDK
reference link: https://dotnet.microsoft.com/download/visual-studio-sdks
It is directly installed to a system admin-accessible path, so no need setting it up. Now, you have to tell VS Code which .Net version to use (whichever you have installed).
Your Unity project will have these two files in the root directory:
Assembly-CSharp.csproj
Assembly-CSharp-Editor.csproj
In these both files search for line (probably 16):
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
Edit version that you had just installed (I had 4.8). Then reopen VS Code. Now everything should work fine.
I found another solution since none of the other solutions were working for me and i was searching for hours.(07/08/2021):
I got the feeling i found the solution for a lot of people since i reinstalled windows recently and simply downloaded everything needed to start without other problems.
I got the same error with .NET, .NET Core or .NET Framework, here are some screenshots of the errors:
In the error output, it says to install the Developer Pack for this framework version. You can find the version in the .csproj file:
By installing the .NET Framework of this version on the dotnet microsoft site: .NET Framework download list
i fixed the error after reloading VSCode and got my Intellisense working for Unity.
TLDR:
My fix was too install .NET Framework version 4.7.1
If you still can't enable IntelliSense, make sure you have VS Code opened in the same directory as the .sln file (I had mine opened deeper in the Assets before).
Source:
https://code.visualstudio.com/docs/other/unity
Though the question is 2 years old, the problem pops up occasionally, just like happened to me.
I had the issue myself, so this one is possibly the first that should be checked.
"Install .NET Framework 4.6 Targeting Pack"
WHY?
First of all, I work with dotnet core, not the standard, so I don't have standard libraries installed on my computer. When I started trying Unity, and VS Code with it, this was the missing part I wasn't aware of.
When I hit the issue, I searched the net a while and see this question. Took me another while to notice this framework sentence in "Enabling code completion" section of VS Code and Unity page. So I tried and now I am happy I tried.
Just don't forget you need to restart at least VS Code to get the intellisense working.
PS: Framework version may, and will most possibly, be changed depending on what year we are in, and which versions we use. So if "4.6" is not working then you probably need another version.
PS2: If it is Mac you are looking for, follow the same link above and find the same section I mentioned above to get a link for .NET SDK.
Follow these steps:
Go into your Unity project.
Go to Edit.
Go to Projects preferences.
Go to External tools.
In line "External Script Editor" you have to change to "Visual Studio Cummunity 2019..."
then it should work.

Using VS2017 and VS2015 C# projects in the same location, side-by-side

Is anyone out there using Visual Studio 2015 and 2017 .CSPROJ files alongside each other in the same folder? Are there any other incompatibilites, besides the solution and project files that I should worry about?
Basically what I want to do is allow our developers to continue to use VS2015 and those projects -- just for a while -- while all still working on exact same set of same code files. I don't want to move/change anything else.
I've already created all the new project files and solution file. But 'm wondering if I can just put them in the same physical disk folder alongside each other and have everyone go merrily about their development tasks with either VS2015 or VS2017.
The duplication of work synchronizing the project files themselves is not a concern. I just want to make sure there aren't any OTHER format differences that might cause some sort of build/run problem for me.
Is anyone else out out there doing this? Is this workable?
There is not any incompatibility, but you should check when you are creating a new project in VS2017 the kind of project, you should have two things in mind, first, when you are creating .net projects, you have to keep using the old .net framework instead of .net core, and second (only if you are going to create desktop/libraries/console projects), you need to use the Common option instead the new option (check on the dropdown to select the .net framework version that allows you to select versions lower than 4.5), cause if not, then you have the incorrect kind of project selected and this kind of project doesn't work in VS2015 as they change the structure of the .csproj file. Hope this little explanation helps you.
Update
What I wanted to say with this explanation is that every projects that comes from VS2015 or 2017 if they have the same structure (same old kind of .net framework), then you can do what you want to do, but if for some reason you need to make a .net core, then this will not work.
Cheers.
Just be aware that VS2017 supports C# language version features that 2015 does not. If anyone uses those features you will not be able to build the projects in VS 2015.
You can enforce language version in the .csproj files but this is done per BuildConfiguration and can be tedious to configure for larger solutions with many projects.
To make the changes
Right click the Project and select Properties
Then Build Then
Advanced (Bottom Right corner) General > Language Version
Change to C#6.0
Overall it is possible but you may need to retain VS2015 if you have any SSIS or SSRS packages as the tooling is still not available for general release (Oct 17) and is still in preview.
You should be able to run Visual Studio 2015 and Visual Studio 2017 side by side without any issues. Our application ran on both Visual Studio 2015 and Visual Studio 2017 before every developer migrated to VS 2017.
You do need to keep in mind few things though:
Visual Studio 2017 by supports C# 7.0. Make sure that you use same language version in both the IDEs.
VS 2017 also supports stuff like editor.config. I would suggest to avoid using it (though I feel it should not be an issue)
If you are using on .NET Core project without csproj. Do not think you would be able to upgrade it.

Visual studio code auto-complete

I have just downloaded unity and saw that now it supports Visual studio code, I downloaded it and made it the default editor.
After trying to edit a script, it prompted me to download c# extension and I did, but there is no auto-complete for unity functions. How can I get that? I'm on Mac.
Any help is appreciated.
Maybe too late, but for future comers ...
There is an extension now for visual studio code called MonoBehaviour Snippets by Rachod Petchpho.
Press Ctrl+shift+x in the IDE to open extensions panel then search for MonoBehaviour Snippets, install and reload the IDE, now you will find all the autocomplete for the function names and objects just like MonoDevelop.
I had the same situation and I bang my head to the wall for days. There was no solution on the net as there are few people using Unity on linux with Visual Studio Code. I finally removed mono and went to their site and downloaded the Visual Studio build (even though we use Visual Studio Code). Then volaaa. Auto complete and suggestions related to Unity functions were there. Of course after installing the necessary extensions.
https://www.mono-project.com/download/vs/
I had the same problem with Unity + VS Code combo.
I have found an extension called Unity CodeSnippets
I highly recommend to download it. This is much better than any of other snippets collection for VSCode.
Intellisense (Autocompletion) is a pure workflow of .Net Environment. So, you need to have .Net 'Developer pack' (not Runtime) installed on your system as it installs all three necessary components below:
.Net framework
.Net Target pack
.net SDK
reference link: https://dotnet.microsoft.com/download/visual-studio-sdks
It is directly installed to a system admin-accessible path, so no need setting it up. Now, you have to tell VS Code which .Net version to use (whichever you have installed).
Your Unity project will have these two files in the root directory:
Assembly-CSharp.cs
Assembly-CSharp-Editor.cs
In these both files search for line (probably 16):
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
Edit version that you had just installed (I had 4.8). Then reopen VS Code. Now everything should work fine.
You can use the unity integration plugin:
https://code.visualstudio.com/Docs/runtimes/unity
Follow the instructions to get set up. It seems a lot of things to do but I think that's the best one.
If you still hit the issue even by using that plugin then follow this issue at their github page.
https://forum.unity.com/threads/cant-get-vscode-to-work-properly-with-unity.538224/
there are people that found a workaround.
unityoracle user said:
"This issue is that Unity Editor expects the file used to launch VSCode to have a specific name. "
and:
"Specifically, creating a symlink named "code" that opens VSCode fixed this issue"
for me, it works by downloading .NET Framework 4.7.1 Developer Pack
here
here is the link
Follow the steps from https://code.visualstudio.com/docs/other/unity
Then in unity editor, set VS Code as the default Script editor:
Edit -> Preferences -> External Tools -> External Script Editor
Right below, set Embedded packages and Local packages to true
i used these methods and it worked
Change in External Tools: Edit -> Preferences :choose " Visual Studio Code"
Open file : Assembly-CSharp-Editor in your project folder and Download the Framework Version that is the same as the version in this file EX: v4.7.1
Open VScode tool - Settings - >code lens and tick.
source from here:
https://www.gamesmobile.one/2022/01/visual-studio-code-auto-complete-with.html
I installed an older version of c# vscode extension, version 1.16.21, and it is working.

generic.xaml not being re-packaged when modified

What I have installed...
Windows Vista Ultimate Service Pack 1
Visual Studio 2008 Service Pack 1
.Net Framework 3.5 Service Pack 1
Silverlight 3.0
My First Problem...
I modify themes\generic.xaml and save the file and run the project and the changes I just made in themes\generic.xaml are not inside the assembly. I have used reflector to see what is in themes\generic.xaml and it is the previous version of the file.
Second Problem...
Upon realising this was happening I decided to test with modifying a C# file and I get the same problem - on compile it does not recoginise the code changes.
Note:
Before building all changes are saved via Visual Studio Option "Project and Solutions"->"Build and Run".
Using Local IIS Web Server
What I have tried...
I uninstalled ALL Silvelight, .Net Framework and Visual Studio components and re-installed only to have the problem re-occur.
Update 1:
Looks like the XAP file is not being updated. Just worked out this is only a problem when using F5 (Start Debugging) not when doing a Build Solution(Ctrl - Shift B or F7).
ANY suggestions welcome !
I finally worked it out and I am almost embarrassed to say what the solution is.
In Visual Studio 2008 goto Tools->Options->"Project And Solution"->"Build and run"
Turn OFF Option "Only Build Startup Projects and dependencies on run"

Categories

Resources