Related
I'm on Linux and currently trying to run a simple Hello World-program in C# using visual studio code.
The VSC for Linux, Arch Linux to be precise, is 'code'. I installed the extension 'Code Runner', but everytime I click on the 'Play/Execute'-Button in the upper right corner, it says:
[Running] cscript "/path/to/my/file/learning.cs"
/bin/sh: cscript: command not found
I can compile it with csc learning.cs and executing it with mono learning.exe just fine, but the built in code-runner VSC extension does not seem to work. I thought about adding 'cscript' to PATH but I don't know where it is located at.
I read on here that this problem exists for quite some time now, maybe someone found a solution? Or I am just really blind or dumb for not seeing an obvious fix.
Any help is greatly appreciated.
Fix:
in vscode, go to preferences, then settings. Type Code-runner: Executor Map
Click Edit in settings.json
Under "code-runner.executorMap":
replace
csharp: cscript
with
csharp: dotnet run
So far i only wrote c# code in visual studio and for unity. However i decide to work on my C# fundamentals a bit instead of coding only for Unity, hoping to improve my understanding about OOP and designing my objects.
I started to follow pluralsight c# path where dotnet core used with visual studio code instead of regular visual studio. Next 18 hours i actively tried to run Hello World application. After i tried everything google has to offer yet failing, tens of times uninstalling and installing stuff yet failing.I somehow managed to do trick by creating an empty folder at "C:\Program Files (x86)\Microsoft SDKs\NuGetPackagesFallback" by following the tail of error messages.
You may comment something like, "you have learned a valuable lesson" etc. which may be true but i don't want to. I don't want to be an expert at making compilers run, i don't want to learn how they function. I just want to make my code better.
Now i could run Hello World app by using dotnet run from command line where i felt nice, finally i can move on to improve my OOP stuff. But wait VS Code didnt want to proceed.
After couple hours of tweaking i could finally run the code but i am not happy with it. The reasons why, and what i am asking is below.
VS Code build .json files with this lines..
tasks.json had "/property:GenerateFullPaths=true",
which i had to replace with "${workspaceFolder}/src/GradeBook",
and launch.json had
"program": "${workspaceFolder}/bin/Debug/<target-framework>/<project-name.dll>",
i had to replace it with
"program": "${workspaceFolder}/src/GradeBook/bin/Debug/netcoreapp3.1/GradeBook.exe",
What i don't mind is adding "/src/GradeBook" only if i have to do that when i use subfolders for project. I don't know if the problem with tasks.json was related to this. But do i have to fully replace tags like <target-framework> when .csproj file has a definition of target framework <TargetFramework>netcoreapp3.1</TargetFramework> .
I really do not understand how these .json files work, why auto-generated files do not do their job and how i can live interacting minimally with those. What are the minimal steps i "have" to take care of myself. Can somebody please explain me and please treat me like i am 3 years old with 5 IQ because i fell like one when i am dealing with these stuff.
After struggling a bit more i somehow found this.
https://www.reddit.com/r/vscode/comments/6ozrwj/is_there_really_no_other_way_of_adding_required/
There was a reply
Adding assets can be done with dotnet.generateAssets command. You can
invoke the command using the command palette (Ctrl-Shift-p), search
for .NET: Generate Assets for Build and Debug.
Which was looking exactly like the thing but unfortunately i got error message :
"OmniSharp server is not running" / "server has been stopped or not
started"
I somehow reached https://github.com/OmniSharp/omnisharp-vscode/issues/32 where was this comment
BedmanGit commented on 10 Jan 2019 Add path to environment works
http://reddyinfosoft.blogspot.com/2017/07/cannot-start-omnisharp-error-error.html
I added Windows/System32 to PATH. VS Code asked me if i want to generate necessary assets. I clicked yes. My project worked without me having to manually editing .json files.
I am able to edit my code in debug mode but then pop up shows the error that
Edits were made which cannot be compiled. Execution cannot continue until the compile errors are fixed
but error list is empty and i have checked enable edit and continue.
I am using vs2010.
Cleaning and restarting has not solved the problem.
This problem can occur when your workspace broke. Just close Visual Studio, delete (or better first just rename) the .vs folder and start Visual Studio again.
It can even happen with VS2017.
In Visual Studio
Debug --> Options --> Debugging --> General --> uncheck Enable Edit and Continue
I had the same problem (VS2017), for me it was enough to menu item Build and click Clean Solution
Then Rebuild Solution and everything worked fine again.
Potentially this is caused by Visual Studio's Edit & Continue feature.
A workaround is to disable this feature:
Debug --> Options --> Debugging --> General --> uncheck Enable Edit and Continue
Solution taken from here.
Also answered here.
I've had this problem with Visual Studio 2008, 2010, and 2013. I wrote a batch file I keep in the solution folder for each of my projects when this problem crops up. Expanding on what Vijay said, this cleans out the bin and obj folders. Sometimes Visual Studio will have the folders locked and I have to close it, but after I clear these out the problem goes away... for a while. I'm not sure of the underlying cause, I believe the binaries and the code in memory is somehow getting out of sync. But this allows a quick close, clean, open solution.
#echo off
cls
dir bin /s /AD /b > clean.tmp
dir obj /s /AD /b >> clean.tmp
for /F "tokens=*" %%A in (clean.tmp) do echo rmdir /S /Q "%%A"
echo This command will remove ALL BIN and OBJ folders in this tree.
echo To run the commands as listed ...
pause
for /F "tokens=*" %%A in (clean.tmp) do rmdir /S /Q "%%A"
del clean.tmp
pause
I had this problem as well in a c# project. It turns out it was because I had recently enabled the "Enable native code debugging" option.
Turning it off restored the functionality.
There seems to be a regression in Visual Studio 2019 16.9 that affects this features. If you are experiencing this issue check https://developercommunity.visualstudio.com/t/Edits-were-made-to-the-code-which-canno/1370525#T-ND1386337 in order to know when the fix will be available.
For Enterprise/Professional versions, a downgrade to 16.8 would be advised.
Hope this helps people experiencing this bug (like myself) since this is the first SO post that comes out in searches.
There is another possible culprit:
It may be a problem with one of the projects that are included in the solution.
I had the exact same problem, as did a co-worker of mine, and the culprit was one of the projects in our .sln file; a WinForms application that was also started in connection with several other projects in the same solution file.
The remedy was simple:
Remove the WinForms project from the solution, and start a separate Visual Studio instance, where the WinForm project was separated from the rest. And then it worked. I think there is some file edited when the WinForms application was run, that changed the code, for some reason.
I am using Visual Studio 2017 Community updated as to date.
After hours spent trying all the solutions posted in this thread highlighted by Hao Nguyen in the comments above, the only solution that worked was to remove the Workspace and Map&Get again.
To remove the Workspace, File → Source control → Advanced → Workspace → Remove.
Sorry for a bit late answer but might be it can help out some other technologist. I had faced the same issue in my VS2019 & VS2022 and find 2 solutions.
Solution 01:
i. Tools/Debug => Options => Debugging => General --> Enable Edit and Continue [uncheck it]
ii. Rebuild Code
iii. Tools/Debug => Options => Debugging => General --> Enable Edit and Continue [check it again]
Solution 02:
i. Close your Visual Studio.
ii. Delete the .vs hidden-folder (For safe side, rename it instead to delete)
iii. Reopen your Visual Studio and run the project again.
Hope it'll work!
This type of error message could occur in three categories as I know so far:
Visual Studio setting, like you have to set Visual Studio IDE environment properly
Source control related
Your method of code does have an interop related API that doesn't like to be edited in the debugging mode
Most people could fix their problem by going through #1. To make sure if your Studio setting is right, simply run a new and very small solution, and edit it in debugging mode. If that gives you the same error message, then your problem is with Bill Gates:), go fixing the configurations. If no error, shift focus to your own code.
Try to edit in debugging mode in a separate method in your solution. This error could be method dependent if the critical part is not in the global area. After narrowing down the problem to a method, well, you are close to a good luck. Commenting out most or all contents in the method, and gradually un-comment the lines. You will eventually ping down to the point where the problem gets triggered.
In my case, it is the Excel file application that caused the problem. The solution: I created the objects of Excel app, workbook, and worksheet as global variables, and open and defined them in one of my main method. Somehow, after doing so, Bill Gates doesn't like to me fool around the method any more in debugging mode. My trick to go around Bill is to write the workbook opening and worksheet definition in a small separate method, and just call that it from the original method. After that, I can happily edit any part in the big method during debugging run time! Still, I cannot do that in that small method that just contains the workbook and worksheet handling. Well, that is Bill's comfortable work place:) I don't need to.
I am currently trialling Visual Studio Online with an On-Premises build server. I have managed to move a number of projects into VSOnline but for some reason have hit a brick wall with one.
The project appears to build correctly but when I get to the end of the build I get the following error:
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Microsoft.Common.targets (4291): The command "copy *.dll ........\PROJECT NAME\bin\Debug /y" exited with code 1.
I have deleted the project and re-created to be sure there was nothing wrong with my initial setup. As far as I can tell I have followed exactly the same process to create this project as I have 2 others that have both worked perfectly.
When I take the MSBuild command that is actually executed and run that directly on the build server it works fine.
Is there any way to get more information about what is going wrong? Has anyone else come across something similar?
Switch your post build events to AfterBuild.
Always use properties instead of hard-coded names. E.g. use $(Configuration) instead of Debug or Release.
The Post Build events for several of the projects were causing the issue when building on TFS.
I added
IF "$(BuildingInsideVisualStudio)"=="true" ( copy command here )
to the Post Build Events so that they only run when building in Visual STudio and are ignored in TFS Build.
I create a new project, click compile, and get this error:
Build Failed. See the build log for details.
In the build log there is only this:
Building: FirstProgram (Debug|x86)
---------------------- Done ----------------------
Build failed.
Build: 1 error, 0 warnings
Here is what I see:
What causes this error and how do I fix it?
Lots of times dealing with this error. I just closed and reopened. It happens every time I add a solution and then delete it. I think Xamarin Ide is not a really good Ide, not in Mac at least.
In my case, i did`t Indy (or higher) License.
When i started trial period, the problem was solved.
I got the same error when trying to build. Without having noticed I had been logged out of my account, which caused the error. Curious that I wasn't prompted to relog or given information that I wasn't logged in.
Though this is an old post, maybe this could help someone.
In my case, using Xamarin Studio 6.1.4 (build 1), I unchecked
the 'Use MsBuild engine ...' check box under Project Options > Build > General and
the problem disappeared.
I searched for solution online for similar problem, but none solved my problem, then I tried this:
Tools >>> Options >>> Projects and Solutions >>> Build and Run
Then I changed MSBuild output and MSBuild log to Detailed.
Rebuild and the error message will show.
cd into the project path, and hit msbuild on it.
You will then see the error details in the console STDOUT.
I had the same problem after upgrading Xamarin, and in my case it happened even for a x86/desktop Console Application. Turned out to be because I didn't have 4.5.1, which was required by the newer version (I had only 4.5 I think).
I found this entry in the log:
Unregistered TargetFramework '.NETFramework,Version=v4.5.1' is being requested from SystemAssemblyService, returning empty TargetFramework
After googing this error I found https://stackoverflow.com/a/38102386/492336, and the solution was to download .NET 4.5.1 and it worked after that!
I just ran into the same problem using Visual Studio Community for Mac. The system was out of disk space. Freeing up some disk allowed a build to complete successfully.
Try the following options from Build menu:
Clean All
Rebuild All
Then build it again.
If won't help, check your log files for details by going to Help menu and Open Log Directory.
For example by dragging & dropping the log folder into newly opened Terminal window, and run:
tail -f *.log
then run the build again and check the reported logs. Hit Control-C on Terminal when finished.
For better visibility, run:
tail -f *.log | grep -C5 -i error
You can also try to clear cache folder of VisualStudio, e.g.:
$ lsof -p $(pgrep VisualStudio)
$ rm -fr ~/Library/Caches/com.microsoft.visual-studio
I downloaded and installed the packages shown below in the order listed:
JDK 1.6: http://www.oracle.com/technetwork/java/javase/downloads/jdk-6u31-download-1501634.html Please choose the jdk-6u31-windows-i586.exe installer from the list above.
Android SDK: http://dl.google.com/android/installer_r20-windows.exe After the main installer is done, please open the SDK Manager and install the following platform APIs: 7,8,10,12,14
Mono for Android SDK: http://download.xamarin.com/MonoforAndroid/Windows/mono-android-4.4.55.104956787.msi
Reboot Xamarin.
Try building your project from the Powershell command line.
dotnet build
Then, build errors will appear in the command line output.
I encountered this issue today in Visual Studio for Mac 2022 with a Xamarin Forms 5 project. In my case, going to the Solution properties, under Build → General, and unchecking "Build with MSBuild on Mono" worked.
(This might be similar in spirit as #JackGriffin's answer, but it seems to be a solution property rather than a project property.)