visual studio generates executable from C# but where are the obj files? - c#

I have Visual Studio Express 2010 installed, and have used it for a C# project.
Now I am writing a .gitignore file so I can exclude from git the object files that I expect to be generated.
I come from a C++ world mainly.
Trouble is, despite the fact that the target is being generated correctly I cant see any object files (with .obj or .o extension)anywhere in the directory tree of the solution.
Could this be caused by the configuration where they are being sent elsewhere?

To answer your direct question: C# doesn't have a compile step that produces .obj files like C and C++ do.
However, a .gitignore that's appropriate for C# projects is a well-solved problem. Visual Studio will ask you if you want to add the .gitignore to your new git repository when you create it. If you already have a repository, you can just use the community's .gitignore for Visual Studio which is excellent (and what Visual Studio would install for you.)

There aren't any .obj files generated during compilation, but there is an obj directory under the project root that's used to store temporary files. This is the directory that should be in your .gitignore file.

Related

Issue with building single small exe file in Visual Studio

In the older version of the visual studio, it was possible to build a small "Hello World" application that has a single .exe file and size around 200KB. I started to use a new version of Visual Studio and I have with this simple task.
When I build it with parameters:
<PublishTrimmed>true</PublishTrimmed>
<PublishReadyToRun>true</PublishReadyToRun>
<PublishSingleFile>true</PublishSingleFile>
The output is single .exe, but with the size around 25MB. When I build it as "Framework dependent", the .exe is around 150KB, but it has additional 2 .json configuration files.
Is it possible now to publish a single small .exe file without the .json configuration files in Visual Studio?
You can try to use Costura.Fody to make a single exe without another file.
The following link is a similar question, you can refer to it to solve this problem.
How to make a Single exe file from c# assembly and dll?

Visual Studio Extension, dll deployment and locking [C#, VSIX]

I need some help using CodeAnalysisCSharp in my VSIX project.
The issue I'm currently having is that the necessary dlls are not "deployed" when installing the extension. I've had to manually copy/paste these files to the C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE folder, for it to "work".
System.Numerics.Vectors.dll
System.Runtime.CompilerServices.Unsafe.dll
System.Memory.dll
Microsoft.CodeAnalysis.dll
Microsoft.CodeAnalysis.CSharp.dll
I have created an extension project and added a custom command. This command should be able to use the CodeAnalysisCSharp to navigate the syntax tree of a C# file.
I'd very much like for the installer file (.vsix) to be able to deploy the dll dependencies, just like you'd expect it to, I just don't know how or where to look to make this happen.
Thanks in advance.
I found out that if you use the vsixmanifest file to add assets, and give it a sub folder, it doesn't get packaged correctlty. The files will be copied correctly, but the reference to the dlls are not correct, so you get a "dll not found" exception.
In general the vsixmanifest designer, seems to be riddled with quirks where you need to edit the xml code to be sure that the values are set correctly.

How to exclude folders when using TFS in vscode?

I am using Visual Studio Team Services extension in VS code for check in. https://marketplace.visualstudio.com/items?itemName=ms-vsts.team
I am now trying to check in change in angular project, but I am annoyed by excluded 16000 files which are from node_modules:
How can I exclude those files from source control? In Visual Studio I used .tfignore file, how about vscode?
I had the same problem creating a dotnet core 2 cli react project using visual studio code and TFVC. I created a .tfignore file in the root (same place as the .gitignore).
Then I copied the content in the .gitignore file into .tfignore file, save and done...
So I followed everything that the others mentioned, but was missing the following, for .tfignore to skip the files:
Place the following in you Visual Studio Code's settings.json file.
"tfvc.restrictWorkspace": true
settings.json location:
File - Preferences - Settings (top right-hand corner(Open Settings (JSON)))
That I found the answer here.

How do I create an installer for a class library in VS 2013?

I am hoping to get some help to figure out how to create an installer in visual studio 2013.
My class library project generates a DLL called DataTest. The solution also has an xml file called config.xml. Currently when I build the solution the DataTest DLL ends up in the bin folder (and the config.xml is just a static file somewhere). What I want the installer to do is copy/install the DataTest DLL to C:\MyData\Test and the xml file should end up in C:\MyData\Config.
I have found this http://geekswithblogs.net/TarunArora/archive/2014/04/24/visual-studio-2013-installer-projects-ndash-hello-world-installer.aspx which seems like a good place to start but I don't have much experience with the different configurations in VS so I don't really know how to do what I want to do.
Thanks
I'm assuming you want an MSI file to do the install because you posted that link, so you're using the Visual Studio Installer projects extension.
This might also help, old but still applies:
https://www.simple-talk.com/dotnet/visual-studio/getting-started-with-setup-projects/
Configurations in Visual Studio don't really have much to do with this. The Bin, Release, Debug folders in your build are nothing to do with where you want to deploy the file on the target system. For example, if you have a Dll that you want to install in the Common Files Folder then you select that folder in the File System view of the setup project and just drag and drop the file in there. The same principle applies to the Program Files folder, which is the usual place for applications.

Avoiding CopyFilesToOutputDirectory build step

With my C# project in Visual Studio 2010, I noticed that msbuild compiles to a \obj directory, and then copies the files to the real output directory:
CopyFilesToOutputDirectory:
Copying file from "obj\x86\Debug\Manager.exe" to "bin\Debug\Manager.exe".
There is no custom msbuild script, it's all the visual studio defaults. Is there any way to make it build directly to bin\Debug\Manager.exe; circumventing the "CopyFilesToOutputDirectory" step?
I just wonder why do you want that. There is no easy way since by default obj folder is used when compiling the assemblies (executables and libraries). Only when it is successful the output is copied to bin folder. That is why is visual studio can successfully run the last successful build which is run from bin. So in essential there needs to be obj folder. You can extend the build mechanism, alter and tweak a bit by using this builder and not depending on the default builder by seeing this link
No there isn't, not really anyway. Because the obj folder is holding the temporary (not linked) files during the build.
More reading: What are the obj and bin folders (created by Visual Studio) used for?
and here: VisualStudio: How to save the obj folder somewhere else

Categories