C
C#5mo ago
GymGoer

Stupid question about Visual Studio

Hello everyone, I feel like I'm losing my mind with Microsoft Visual Studio. My college wants me to rename the .cs file in the solution explorer but I don't see anything like presented on the screenshot with instructions (picture in light mode). Official microsoft guide has solution with project (1 out of 1), and c# program tab with Dependencies and Program.cs in it, but I have empty solution. Any good videos on how to configure this? Spent 2 hours trying to configure Visual Studio and so far having only trouble.
No description
No description
59 Replies
WEIRD FLEX
WEIRD FLEX5mo ago
you could paste solution file here
GymGoer
GymGoer5mo ago
There is no solution file
WEIRD FLEX
WEIRD FLEX5mo ago
you have to have at least a csproj
GymGoer
GymGoer5mo ago
There are in fact no files at all, it doesn't let me do anything, I have Console.WriteLine written there, but it doesn't let me run or debug, just "Attach..."
GymGoer
GymGoer5mo ago
No description
Angius
Angius5mo ago
Is it just a loose .cs file? Or do you have a proper project with a .csproj and all set up?
GymGoer
GymGoer5mo ago
No, I made a project Is it in "views"?
Angius
Angius5mo ago
It's on your disk
GymGoer
GymGoer5mo ago
No description
Angius
Angius5mo ago
Aight, that seems fine And did you open the project, the solution, or the folder? Just to make sure, close VS and open the solution by double-clicking the .sln file
GymGoer
GymGoer5mo ago
Did that, everything seems same, so I guess it was solution opened Still cant run anything tho
Angius
Angius5mo ago
Huh Try opening it by double-clicking on the csproj? Maybe the solution file is busted
GymGoer
GymGoer5mo ago
No description
Angius
Angius5mo ago
Ah Now we're getting somewhere Open the csproj in any text editor (Notepad, Notepad++, etc) and paste the contents here
GymGoer
GymGoer5mo ago
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <OutputType>Exe</OutputType> <TargetFramework>net8.0</TargetFramework> <ImplicitUsings>enable</ImplicitUsings> <Nullable>enable</Nullable> </PropertyGroup> </Project>
Angius
Angius5mo ago
Aight Open Powershell or CMD and execute dotnet --info command, paste the output here
GymGoer
GymGoer5mo ago
Host: Version: 8.0.1 Architecture: x86 Commit: bf5e279d92 RID: win-x86 .NET SDKs installed: No SDKs were found. .NET runtimes installed: Microsoft.AspNetCore.App 8.0.1 [C:\Program Files (x86)\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 5.0.17 [C:\Program Files (x86)\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 6.0.26 [C:\Program Files (x86)\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 8.0.1 [C:\Program Files (x86)\dotnet\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 5.0.17 [C:\Program Files (x86)\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 6.0.26 [C:\Program Files (x86)\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 8.0.1 [C:\Program Files (x86)\dotnet\shared\Microsoft.WindowsDesktop.App] Other architectures found: x64 [C:\Program Files\dotnet] registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x64\InstallLocation] Environment variables: Not set global.json file: Not found Learn more: https://aka.ms/dotnet/info Download .NET: https://aka.ms/dotnet/download
dotnet command - .NET CLI
Learn about the dotnet command (the generic driver for the .NET CLI) and its usage.
Microsoft
.NET Downloads (Linux, macOS, and Windows)
Official .NET downloads for Linux, macOS, and Windows. .NET is a free, cross-platform, open-source developer platform for building many different types of applications.
Angius
Angius5mo ago
Seems you have no .NET SDK installed, just the runtime
GymGoer
GymGoer5mo ago
Is it supposed to be installed separately from Visual Studio?
Angius
Angius5mo ago
It should be installed with VS, yeah Perhaps you're missing a workload? Open the VS installer and check that you have it It should be something like "programming classic applications for .NET platform"
Angius
Angius5mo ago
In the installer, click on Modify button
No description
GymGoer
GymGoer5mo ago
No description
Angius
Angius5mo ago
Huh, so it is there What's the VS version?
GymGoer
GymGoer5mo ago
2022
Angius
Angius5mo ago
And this?
No description
GymGoer
GymGoer5mo ago
.4 but yeah
Angius
Angius5mo ago
Yeah that's good Aight, let's try to install the SDK separately You can download it and run the installer, or use the Winget package manager and winget install dotnet-sdk-8
GymGoer
GymGoer5mo ago
Alright, getting installed Is it somehow related to azure?
Angius
Angius5mo ago
Not at all I mean, maybe MS is storing the installer or something on Azure, they probably are But nothing directly tied to it
GymGoer
GymGoer5mo ago
Typical microsoft Alright, SDK's installed
Angius
Angius5mo ago
Cool Close the cmd/pwsh, reopen it, dotnet --info again Or even just dotnet --list-sdks
GymGoer
GymGoer5mo ago
No SDKs found
Angius
Angius5mo ago
Well damn Okay, it could be an issue with env variables then
WEIRD FLEX
WEIRD FLEX5mo ago
do you need to be admin to install it? probably not but just checking
GymGoer
GymGoer5mo ago
No description
Angius
Angius5mo ago
Ah So it's most probably is an issue with the PATH variable Open the environmental variables editor in control panel Typing edit environmental variables in the start menu should get you directly there
GymGoer
GymGoer5mo ago
This?
No description
Angius
Angius5mo ago
Yep Click that Enviromnent Variables button
Unknown User
Unknown User5mo ago
Message Not Public
Sign In & Join Server To View
MODiX
MODiX5mo ago
* Open powershell in a terminal in admin mode as in the following video: https://cdn.discordapp.com/attachments/569261465463160900/1157744344183341156/20230930-1822-10.7436061.mp4 * copy/paste the following script * it will tell you if it detects invalid Path setup * Press Enter to confirm
$OldSysPath=[System.Environment]::GetEnvironmentVariable('PATH', [System.EnvironmentVariableTarget]::Machine); `
$Hasx86=($OldSysPath.Split(';') | ? { $_.StartsWith('C:\Program Files (x86)\dotnet')}).Count -gt 0; `
if ($Hasx86) {
Write-Host "**********************************************************************"; `
Write-Host "If you're seing this message your SYS PATH is improperly set" -ForegroundColor Yellow; `
$NewSystemPath=$OldSysPath.Replace('C:\Program Files (x86)\dotnet', 'C:\Program Files\dotnet'); `
Write-Host "**********************************************************************"; `
Write-Host "Your Old PATH was:" -ForegroundColor Green; `
Write-Host "$($OldSysPath)"; `
Write-Host "**********************************************************************"; `
Write-Host "Your New PATH will be:" -ForegroundColor Green; `
Write-Host "$($NewSystemPath)"; `
Write-Host "Press enter to continue (Ctrl+C to ABORT)" -ForegroundColor Red -NoNewLine; Read-Host; `
Write-Host "**********************************************************************"; `
[System.Environment]::SetEnvironmentVariable('PATH', $NewSystemPath, [System.EnvironmentVariableTarget]::Machine) `
}
$OldSysPath=[System.Environment]::GetEnvironmentVariable('PATH', [System.EnvironmentVariableTarget]::Machine); `
$Hasx86=($OldSysPath.Split(';') | ? { $_.StartsWith('C:\Program Files (x86)\dotnet')}).Count -gt 0; `
if ($Hasx86) {
Write-Host "**********************************************************************"; `
Write-Host "If you're seing this message your SYS PATH is improperly set" -ForegroundColor Yellow; `
$NewSystemPath=$OldSysPath.Replace('C:\Program Files (x86)\dotnet', 'C:\Program Files\dotnet'); `
Write-Host "**********************************************************************"; `
Write-Host "Your Old PATH was:" -ForegroundColor Green; `
Write-Host "$($OldSysPath)"; `
Write-Host "**********************************************************************"; `
Write-Host "Your New PATH will be:" -ForegroundColor Green; `
Write-Host "$($NewSystemPath)"; `
Write-Host "Press enter to continue (Ctrl+C to ABORT)" -ForegroundColor Red -NoNewLine; Read-Host; `
Write-Host "**********************************************************************"; `
[System.Environment]::SetEnvironmentVariable('PATH', $NewSystemPath, [System.EnvironmentVariableTarget]::Machine) `
}
Unknown User
Unknown User5mo ago
Message Not Public
Sign In & Join Server To View
Angius
Angius5mo ago
Or use pwsh, sure lol
Unknown User
Unknown User5mo ago
Message Not Public
Sign In & Join Server To View
GymGoer
GymGoer5mo ago
Alr, so run the script, now sdk's should be in place?
Angius
Angius5mo ago
Yep
GymGoer
GymGoer5mo ago
yyeeaaahhh, sdk 8 installed
Angius
Angius5mo ago
Nice
GymGoer
GymGoer5mo ago
very based and now I have dependencies and all that stuff from youtube tutorials Thank you very much guys, big help, I'd probably bash my head on the wall for whole day without you
Angius
Angius5mo ago
As a side note, I wonder if putting it somewhere online and changing the bot message to use iex would be less intimidating lol It's an all too common issue for... some reason
Unknown User
Unknown User5mo ago
Message Not Public
Sign In & Join Server To View
GymGoer
GymGoer5mo ago
Microsoft magic
Unknown User
Unknown User5mo ago
Message Not Public
Sign In & Join Server To View
Angius
Angius5mo ago
Instead of the wall of code it'd be
iex ((New-Object System.Net.WebClient).DownloadString('https://dotnet.org/fix-dotnet.ps1'))
iex ((New-Object System.Net.WebClient).DownloadString('https://dotnet.org/fix-dotnet.ps1'))
or w/e Yeah
Unknown User
Unknown User5mo ago
Message Not Public
Sign In & Join Server To View
Angius
Angius5mo ago
Ah, nice, I copied from Chocolatey lol I think
iex (iwr 'https://the-url').Content
iex (iwr 'https://the-url').Content
might also work But all that's just bikeshedding
Unknown User
Unknown User5mo ago
Message Not Public
Sign In & Join Server To View
Angius
Angius5mo ago
OMEGALUL mean, it's already possible, might as well make it more ergonomic lol
Unknown User
Unknown User5mo ago
Message Not Public
Sign In & Join Server To View
Angius
Angius5mo ago
I wonder if there's an issue I could upvote...