Differences in a program's directory between vs and vs code - c#

I am making a program that involves looking for a program's directory. I was making this in visual studio, until today, where I decided to try visual studio code.
Immediately I ran into an issue, with the program not being able to find a file that it should open. I am using Path.GetDirectory() to find the location of the program and using that and combining it with the path to a text file in order to open the said text file
After doing a bit of testing, I found that in vs code the directory it uses to run the program to the directory in visual studio. (Visual Studio uses the location of the .exe file while Visual Studio Code uses the program.cs file directory)
So does anyone have any ideas as to why visual studio code uses a different directory compared to the visual studio? And is there a way for the program to always look for the .exe file over the .cs file

Well, I'm not sure why it is that these are the defaults, though I imagine it is because VS Code is more focused on quick development, while Visual Studio is more focused on production development, but I do know how to change them. In Visual Studio, right click (or Alt+Enter) on the project, go to the Debug tab, and change the working directory field.
In VS Code, go ahead and change the "cwd" field in launch.json to whatever you want it to be. You can use these variables in there.
Visual Guide for Visual Studio:

Related

Visual Studio MSBuild output log file

Where is the log file located? I'm doing a build and I can't find where that file is. Everything online says it's $IntDir, but it looks like it's only for CPP projects, not .NET. This is Visual Studio 2017 on a regular .NET console project. I can't locate the file anywhere. If I choose to do "detailed" in the output, it's far too large. I'd like to get detailed info in the log file only.
I know you can do things via msbuild directly, but I'm trying to figure out what Visual Studio is doing that's different from what I'm doing via MSBuild directly so I can replicate what VS is doing.
Unfortunately, there is no log file for managed projects - you can save a file from the output pane.
You may also be interested in using the MSBuild Log Viewer, which has a VS plugin that lets you save binary-format MSBuild logs from Visual Studio, then open them in the viewer.

Do we need to add the files in the debug/release folder to create a setup in Visual Studio?

I have created a setup file for my Winform project in Visual Studio 2013 but it won't run after the installation. When I use debug or release mode in Visual Studio, it will run.
A closer investigation, I found out that there's lot's of .dll, .config, .cs, .bin, .manifest in the debug folder as well as the release folder. I think they are the files created when I run debug mode or release mode.
Do I need to include all these files from the debug/release folder to the setup file system when I create my setup? Any idea how to check why my app won't run?
The files in the Debug folder must not be distributed, it is against the terms of you EULA for Visual Studio.
You need the release files and unless you are running on the build machine you may need some extra dependencies, You will be told about these in the error messages that are displayed.
More than that I can't help you with, because you haven't said what the error is, unless its no error in which case check your shortcut.
If the Application runs fine in the Debugging Mode of visual studio, then it means that you are not creating the setup file properly. You have to manually add all files that appears in the
../bin/Debug
folder of your project to after adding the primary output.

What creates the directory "app.publish" in visual studio?

I switched over visual studio 2010 express, to visual studio 2013.
Now, whenever I try to test the code, he says /bin/release/app.publish access is denied, giving back a error and forcing me to manually delete the folder. Every single time.
Why is visual studio attempting to create that path in the first place? Whenever I go there he is empty anyways.
I was experimenting with ClickOnce, then decided against using it, then started noticing a MyApp.application file and app.publish folder in my bin directory. Unchecking "Enable ClickOnce security settings" on the Security tab did the trick for me.

How to open C# Solution

I am relatively new to programming and only have some experience with Python and MATLAB but was given an assignment in which I have to run and test a sample program using .NET. I'm set up with Windows 7 via VMWare running on my Macbook Pro and obviously I've got Visual Studio on the desktop.
I have a zip file of the sample program but am having trouble opening it correctly in Visual Studio. Inside the file there is a Microsoft Visual Studio Solution with the same name as the test program. When I open that I get error messages saying certain file paths are not found (which I assume means that I'm not opening the program correctly).
There are also:
a couple XML configuration files
a Visual C# Project File
Visual C# Source files
other folders entitled 'bin', 'obj', 'Properties'
Again, I know this might be a very rudimentary solution but I have been struggling with it for a few days and was hoping I might be able to find a solution here. Thanks!
If you have extracted it correctly, by double clicking on .sln file should launch the application on visual studio.
You can create new solution and import files and references.

Visual Studio Error and Output Window Contents

I was recently asked by a co-worker if it was possible to automatically output the contents of these windows into a text file automatically each time the solution is built.
I have been using Visual Studio .NET since the original release. I have not witness a way to do this, I also never had the need, so I simply could have glanced over it.
There must be a way to tell csc.exe and MSBuild to output to a file.
I forgot to mention this is a Visual Studio 2005 C# project.
In 2010 (assuming it's the same for all others) each project generates a %name%.log text file in it's own directory by default. The solution does not though, so you may need to concatenate all these files or something similar.

Categories