How do I save a solution in Visual Studio 2017 - xamarin

Coming from a Unix background and used to working with the Makefileto build stuff, I now have to find my way through the maze of twisty little passages known as Visual Studio 2017.
Basically: I just want to save a solution that I've imported into Visual Studio 2017 (e.g. to move it to another machine) to some sensible structure. I am unable to figure out how to do that!
The solution I work with comes from GitHub and the package is about 590 Kbyte and consists of 32 files. (I downloaded the .zip and unpacked it, then opened in the IDE by clicking on the .sln-file.
After running it (unchanged) in Visual Studio, it has ballooned to 4 Mbyte and 134 files. Obviously a lot of temporary files has been created as a result of me running it. Making a copy of this bloated directory structure is not practical - and some other way (i.e. the method for saving used by the guy who shared his solution on GitHub) must exist.
I want to save it with all those temporary files removed.
There is Build » Clean Solution – but it does not seem to get get rid of the temporary files.
I've also tried: File » Save all. I do no understand how this commend is supposed to work. It does not ask where to save tings, but just says "Item(s) saved" at the status bar at the bottom of the screen. Looking at things in the file system, I am unable to located anything saved. To me, it looks like this command does nothing.
I've searched, but so far found nothing for Visual Studio 2017 (recipes for older versions does not seem to work anymore.)
Saving a solution is something developers do a lot, so there must be something obvious I've missed.

There is not really the concept of "Save As..." for a solution. If you want to copy the whole solution elsewhere you would usually just copy the whole folder it's in to somewhere else.
The reasons you have many extra files are:
There will be a .git sub-folder which contains the Git repository. If you don't need to retain any link to this, you can delete / avoid copying this. Depending on how much history is in the Git repo this folder can even be much larger than the solution itself.
VS will create a .vs sub-folder for various housekeeping activities; you can usually avoid copying this.
In each project's folder, after you've built the solution, there will be obj and bin sub-folders. These are recreated as needed at build time and are not needed for a copy.
If you copy everything ignoring the above, you will probably find the size of the target is more as you were expecting.

Related

How to clone a Visual Studio 2019 Solution Without Rename, Windows 10

How do I clone a Visual Studio 2019 Solution? I don't need to rename it. The clone simply needs to go into a different folder, or could even go onto a different disk.
This question has been asked and answered many times, but the solutions don't seem to work for my use case. The simplest solution seems to be to Copy and Paste the Solution folder. But when I try to open the clone with Visual Studio, I get an error code 0x800004005. I have verified that 100% of the files in all the folders and subfolders of the clone are binary identical to the original prior to opening the clone. The original solution still opens fine after making the clone. If I dismiss the error code window, the clone looks fine and seems to behave fine. If I close, Visual Studio and reopen the clone, it seems to open fine the second time without generating the error code. I'm wondering if the clone is safe to use at that point.
A worrisome aspect of this simple cloning process is that there are numerous instances of files in the solution that store the names of other files in the solution, and the names are stored with absolute file paths all the way back to the drive letter C:\ So the simple copy and paste clone has lots of pointers to files that are in the original solution. This seems very wrong. After getting and dismissing the 0x800004005 error code, many but not all of the file paths within files in the clone now point to files in the clone. But some file paths in the clone still point to the original. I would be happier if they all pointed to the clone, and if the error code 0x800004005 never occurred.
Doing a Copy and Paste of the existing Solution folder seems to be complete and correct answer for making a clone of the existing solution when a project does not need to be renamed. This is an answer which has been given before, but I ran into some problems and concerns with using the answer. Some comments are therefore in order.
All the absolute file paths I found in files in the solution were in the .suo file, in .log files, and in .tlog files. These are all temporary files that can safely be deleted. They will be rebuilt or rewritten as needed, and they do not affect the Build>Build Solution process. Also, a Build>Clean Solution will delete the .log and .tlog files in any case.
The file paths used during a Build>Build Solution are all relative file paths and are stored in the .vcxproj files. That is why simply doing a Copy and Paste of the Solution folder will "just work" to make a clone.
I can't explain why I encountered the error code 0x800004005 when I opened the cloned solution with Visual Studio. But it seems to be the case that the error code can be safely dismissed and ignored. It is definitely the case that it can avoided by doing a Build>Clean Solution in the existing solution prior to doing the Copy and Paste of the existing Solution folder to make a clone. I therefore recommend doing a Build>Clean Solution in the existing solution prior to making the clone. I also recommend deleting the .suo file in the existing solution prior to making the clone. That way, none of the traces of the existing Solution folder are propagated anywhere into the clone.

Include in Project slowness with Visual Studio 2010

Our company won a web project from a new client. Their old vendor basically zipped up the code (C#/ASP.NET, including an enormous number of media files) and FTPed it to us and is no longer answering phone calls/supporting it in any way. There's no solution file, no project files, just code.
So I created an empty project locally and moved it to a network path and moved their code inside it because I don't even have enough space to host it locally. Their architecture is suspect, but I need to get it back up and running ASAP so I don't have time to reconsider that at the moment. I opened the project I created, selected "show all files" and attempted to include all of the paths (both media files and code paths) and the application hung. One of the media folders has something like 65,000 files in it. Do I even need to include this?
Regardless, it seems like doing "Include in Project" is taking forever, I've spent hours wrestling with it, trying to do one folder at a time...but often it's just hanging and I have to kill the process. Is there a faster way to deal with this? I tried editing the project file directly but including this media folder made the solution take absolutely forever to load.
Any general suggestions on how to approach this situation?
as long there is no direct reference you don't need to include media files into the project.
I bet those files are just loaded runtime from a procedure. To make sure make a full search for the media folder in the sources.
Imho get just the files to a local store, create a solution, and then add all resources and sources. If needed you can copy the media files later again into the project.
I had the same problem with local files. I probably killed VS2010 three times since it would always seem to lock up. I then recreated the folder structure, but not with the correct name, then save the project, open it with a text editor and change the names to the actual structure. Finally use "Add > Existing Item". It's still slow, but a bit faster.
It's not hanging - if you leave it long enough it will finish. Know what you mean though - it took half a day to include dojo on one of my projects.
You may want to try SharpDevelop to include large folders into your projects - it seems much, much faster than visual studio when given this task. You can then just re-open the project in vs. Hope this helps.

Is there a sensible way to backup Visual Studio C++ solutions without all the "extra" files the IDE creates?

I would like to make a backup of my project, but the folder now exceeds 6.6 GB mainly through extra libraries like boost etc, but even if I just select the folders with my sources, I end up with big files like: .ipch, .sdf and potentially others. To make matters worse I use eclipse to code and VS to compile, so that adds to the mess, although I have the impression that only VS creates big files.
In case shit hits the fan I would like to be able to unpack one archive, and have everything in there like the project settings and solution files, and the sources so that I can easily open it again in VS. I can live with having to re-download boost or other third party libs.
How do you tackle this problem and do I need to preserve file like .sdf?
Answer:
Thanks for all the tips. I will now adopt the solution proposed by LocustHorde because that seems to fit my needs best. I simply want one file that I can take offsite as a safe backup (and I don't want to use an online service). Storing all versions of all files doesn't seem to work towards smaller and simpler and it would be a bit overkill in this case, although I will look to install some version control system because I have no experience with them and I would like to get some...
Final Answer
After having a good look I found that dishing out which files had to be ignored by the winrar archiving was still a hassle. I finally ended up installing Git out of curiosity and liked it. So I now have some of my projects in a local repository. From eclipse I can easily mark files and directories for being ignored, and to make a backup I use git-extensions to clone the repo. I still need to look at purging old versions, which isn't very userfriendly in Git, but seems to be possible at least and then i will just 7zip the folder up. In the worst case I just delete the git database and I just have the last version of my source files. Or maybe I can checkout to another directory. We'll see.
First: Instead of doing a backup, I would strongly recommend using a version control system (VCS) like Subversion, Mercurial, or Git. This is the professional equivalent of a backup, except it maintains every version of every file—not just a copy of the latest version.
Even with a VCS, you will still need to decide which files to check-in to the VCS, and you don’t want to back up files that can be easily re-generated.
For my projects, I generally don’t check-in:
Generated executables (the output in the Release, Debug, x64\Release, and x64\Debug directories).
Pre-compiled headers (the ipch folder)
The browsing database (sdf files)
All of these things can be re-generated by rebuilding your project. If you are working as part of a team, you probably shouldn’t check in:
Your personal settings (.suo)
You can always re-create this if needed.
A particularly nice way to backup your stuff is to put your source in a revision control system. I am using git sometimes, and other times mercurial. Using git I can ignore the files that should not be backed up, by adding them to .gitignore:
Debug
Yokto.sdf
Yokto.suo
*.filters
*.user
ipch
Release
Yokto.opensdf
*.opensdf
*.sdf
With git I can set up a backup repository on a network drive and simply push to it every now and then.
you can write a simple script (batch file) that only zips the types of files you want. suppose, you want to zip all your .aspx, .cs, .config, .xsd files only,
suppose you have winrar installed in your c:\program files\winrar
and your project is in c:\project\MyBigProject
then, just open your notepad, copy paste this, and save as "script.bat" (dont forget the double quotes while saving, you need to save it with double quotes, so that notepad saves as .bat extention instead of .txt)
so to backup (in other words, to zip wanted files) :
"C:\Program Files\WinRAR\rar" a -r0 -ed MyBackup.rar c:\project\MyBigProject\*.aspx,*.cs,*.xsd,*.config
the syntax is like this:
"path to winrar folder" 'switches' "Name of completed rar file" 'folder to zip'
just make sure the paths are in proper order. the "a -r0 -ed" parts are switches, and you can find out all about the switches here:
http://acritum.com/winrar/manual/index.html?html_helpswitches.htm
I use the "Ignore files" switch (http://acritum.com/winrar/manual/index.html?html_helpswxa.htm) to ignore all files and folders that I dont want (with wildcards) and My project is about 86 mb, when It gets compressed just with code files, it comes up to 6mb.
its the best way to do it really. If you need more help, please ask!
edit: Also, Look into SVN (its free!) - I use svn too, and its really helpfull. there is even a free tool called AnkhSvn to integrate into visual studio. its just fantastic!
Doing a "clean" before archiving removes most of what you don't need.
Edited to add:
Of course a version control system is essential for any ongoing project, but that's not what he's asking.

Changing the default Source File Directory in Visual Studio

This is not a work-stopper in any way, but I thought I should ask anyway because it is a little annoying. Let's say I create a new project and start putting source files in a directory other than the default that shows up the first time. Afterwords, whenever I open the project, I have to navigate to the source directory once during that session. Like I said, not a big deal (but if solvable, then it's icing on the cake). Quite a few times I absentmindedly put the source file in the default directory and end up committing that file to the SVN and if I am lucky, going through all the files, removing them, then adding them again.
So my question is, is there any way to specify the default source directory on a per project basis?
I have run into the same nuisance. I like to put the public interface header files for a library in a separate directory, but end up with file directory typos because I forget to navigate to the correct directory when saving a new file. Unfortunately, Visual Studio does not offer a setting to change the default directory for new C++ source files.
I had the same problem when I started using build systems (CMake, Premake) which requires me to keep my project files separate from my source files, which hampered my workflow.
Although changing the default source directory seems impossible, if you aren't afraid to spend money, the workaround I found was to use the Visual Assist extension.
You can bind a shortcut of your choise to the Create File command which creates
a new file relative to the directory or your open file.
I'd also recommend to base one's workflow around the wonderful
Create from Usage command (which I think greatly boosts
productivity) which almost eliminates the need to manually create files.
The extension is great, albeit a bit costly. I would love to see Microsoft incorporate these features directly in the IDE eventually as they are found vanilla in a lot of other IDEs e.g. Eclipse, Intellij.
There might be some free extensions available that does the same thing, but I haven't found any.
Changing the Default Project Folder may help. This page demonstrates how to change the default for Visual Studio 2005, and it should be the same for later versions.

Regenerate missing AssemblyInfo.cs in VS 2005

I'm trying to build a small VS 2005 solution I've just checked out of source control, and I'm getting this easy to understand error:
...\AssemblyInfo.cs' could not be
opened ('The system cannot find the
file specified. ') (The file is fairly
obviously missing)
Because this file's automatically generated, I've never paid it much heed before, and in VS 2003 (which I still work with day to day - pity me) it never seems to matter if it's missing.
So 2 questions:
1. How can I get VS 2005 to regenerate the file.
2. Could anyone explain to me in a couple of sentences what the assembly info file is all about, why it's generated, why it's a good idea to have an automatically generated file critical to my solution building etc etc.
Thanks - Andrew.
Edit: OK, I've googling some more, and it's probably significant that this is in an Nunit Test Project.
Update: Deleting the reference in solution explorer an Alex suggested did the trick, and the project now builds, but I'm not entirely happy with that as a solution. If the file is so unimportant, why is it generated in the first place? And if the file does perform a vital task, what am I missing out on by just deleting it?
Also, is it even possible to get it back? Either by getting VS to regenerate it, or by manually hacking one up (possibly using another as a template)?
This file contains assembly-wide settings like assembly version, name, etc. It is automatically generated when you change those settings using properties pages of the project. You should have this file in the project with sort of transparent icon (I think it is in resource folder or something like this by default). Locate it in the project tree and delete it. Visual studio will stop looking for it during build.
PS: assuming the path starts with .. and not ... then this file should be located one folder up from the project in the source control. So you can try looking there.

Resources