Mark a large number of files as Build Action "None" in Visual Studio - visual-studio

I have a folder containing 12000 images. When I add them to my project they get marked as Resources, but I want to set their Build Action to None. If I select them all and go to the Properties tab and set None, VS starts working and engulfes itself.
Is there another way to do that? Or a way to set the default Build Action for newly added files to None?
Thank you!

Make a backup of your project file (e.g. by committing it to a branch in source control locally) before making manual changes to the file.
Right click the project node in Solution Explorer and click Unload Project.
Right click the project node in Solution Explorer and click Edit yourproject.csproj.
Replace all instances of
<Resource Include="Resources\
with
<None Include="Resources\
Save and close the project file.
Right click the project node in Solution Explorer and click Reload Project.
Optionally you could also remove all instances of these lines and use the following single line instead. You'll definitely want to mark your place in source control so you could undo the change if it doesn't work out like you expect.
<None Include="Resources\**\*.jpg"/>

12,000 files is a good two orders of magnitude beyond what you can reasonably expect to be performant during a build. Just checking if files need to copied can easily take 5 minutes on a spindle drive. Still uncomfortable on a solid-state drive.
You'll need a drastically different approach to solve this. Key approach is that you don't wait for it so cannot get annoyed at the delay. Like spinning this off into a separate project that builds a resource DLL, not included in the solution. Preferably done on another machine, build servers are good for that. Or a completely different approach to packing the files, like sticking them in a ZIP archive. A "wad" in gaming speak of old. Or taking your program to the files instead of the other way around, keeping them stored on disk and telling your code where to find them with a configuration setting.

Related

re-including the entire contents of a folder in visual studio 2013

I have an included folder in visual studio, which contains mainly javascript files, CSS, images, etc. These are not required for the website to run, and are altered not from Visual Studio but from other external processes.
I've been publishing to Windows Azure Websites, which require all files to be included so that they are uploaded as part of the package.
Is it possible to somehow click on a folder in the Solution Explorer, and 're-include' all it's contents?
The only option I found right now is to exclude and re-include, which due to the amount of files takes quite some time. It takes ages to 'exclude' the folder. Then, once it's ready I have to re-include which takes a long time as well. Would like to at least do them in one operation.
Was wondering if there was a better process somehow.
I'm not quite sure why you have exclude them all and include them again. Is it because the file names change or new files created often? If the file names stay the same and just the contents are changing you should not have to re-include them. If the external processes create new files now and then, then you should be able to click the "Show all files" option in solution explorer and then when you load the solution check the directory in solution explorer and any new files there include them.
hope that helps in some way. :)

When you make edits to a file within a project using AnkhSVN, can this be reflected at the project level?

When I make edits to file, TortoiseSVN will show an indication on the folder that file belongs to that there are changes pending to child items. AnkhSVN only shows (red tick) changes to a project when files are added/removed (because the actual content of the project file in this case has changed)
Can you make ankh give any indication at the project level that child items have been edited?
Unfortunately, no. Ankh only shows an indication on modified files, whereas TortoiseSVN can traverse folders recursively and mark those with changed files within them.
If you desperately need this feature, you can try out VisualSVN plugin. It tries to mimic TortoiseSVN behaviour as close as possible. In fact, it uses TSVN dialogs for operations such as Commit or Update, for instance. When you modify a file within a project, it highlights the file, the project this file belongs to, as well as the solution node in the Solution Explorer.
Unfortunately, it's not free (US $49 per seat), but IMO it is worth its price.
The recommended way to see what changed globally in AnkhSVN is the 'Pending Changes' toolwindow. This shows you all interesting files in a single view and allows you to operate on them easily.
You can open the toolwindow via View->Pending Changes.
Try this:
Right Click the File -> Subversion -> Lock
This places a lock on the file so that others cannot edit it.
When you commit, it should unlock the file.
If it does not, Follow the same steps and select Unlock.
Edit: I use AnkhSVN for my svn but it's just me that uses it. If a corporate environment I mainly use TFS which does the same thing (lock/unlock) but it does not allow others to check out.

How to TFS-unmap without losing physical files?

At the moment when unmapping a source on TFS Source Control in Visual Studio 2010, the local downloaded files are removed automatically.
How can I keep them untouched?
Nam.
In VS2012
"You can remove the mapping in the Manage Workspaces dialog (File -> Source Control -> Advanced -> Workspaces...) Pick your workspace and select edit, remove the entry for that mapping. Then hit OK. When prompted to perform a Get you can say "no" and the items will stay on your local disk until you next perform a Get."
I added some more information on to it.
Source: Remove Mapping
Just in case anyone else need help with this because i went for hours searching for the solution....and this is the way to see all the mappings you have and remove them if wanted without deleting local files.
I have not seen this behavior. When un-mapping, are you choosing to re-download all files in the workspace? If so, choose not to do that, and the files should be preserved locally. Keep in mind that TFS is no longer tracking changes at that point, so it could get you into a lot of difficulty if you inadvertently make changes to those files.
What kind of process are you trying to implement that you need to keep these files around after an unmap? Maybe there's a different way to accomplish what you need?
--EDIT--
When you're doing this, files are just files, so you could:
do a Get of all files in that workspace
copy them to another folder on your hard drive
map that new folder
Do an "add files" on everything in the new folder structure
check in.
You will have to rebind all of the projects/solutions to source control when you do this.

How should I organize my Xcode project files?

I'm trying to wrap my head around Xcode's file organization - or lack there of. I can do all I want in project and it looks great with all the "fake" folders and structure. I go look at the file system and boom HUGE mess. I've tried importing files with the Create Folder Reference for any added folder option checked and that works, kinda. I get the structure I want both in Xcode and on the filesystem.
Issues: When I add a file to a folder on the filesystem that is a Folder Reference in Xcode, its not in Xcode when I go look, not even after reloading the project. Files/Subfolders in a Folder Reference can't be moved around in Xcode. When I move them on the filesystem I get red links (can't find the file?) in Xcode.
How do I keep a organized project and filesystem? How can I set up a project to just recognize a folder and show its (current and up-to-date) files and subfolders in my project?
Another issue I seem to run into, if I use a Folder Reference and change a file, the file is not updated in my application unless I do a full clean & rebuild. If I don't use a Folder Reference, all my files are dumped into the Resource folder of the application bundle, not in the nice structure I have in my project.
Should I care at all? Should I just use the fake folders and let everything go everywhere and not care? My application bundle will be a mess, the filesystem will be a mess, but it will all work... I would hope?
Edit:
My biggest reason for wanting an organized filesystem is that the resource files (images, sounds, other datafiles, etc.) are not edited in Xcode. I have to access them in 3rd party apps via the filesystem. If its a mess things are harder to find and maintain in the other 3rd party applications.
Also what happens if I want a structure like the following:
Images/Backgrounds/Name.png
Images/Icons/Name.png
Images/Titles/Name.png
Should I use long filenames rather than folders to organize?
Images_Backgrounds_Name.png
Images_Icons_Name.png
Images_Titles_Name.png
I also wish Xcode automatically kept itself and the file system in sync.
So much so, that I spent an hour doing so manually for a project called acani-iphone on GitHub. Basically, I just moved some of the files around using Finder, creating new folders as I pleased. Then, I switched back to Xcode and saw that the files I just moved were now red (because Xcode was thinking they're where I moved them from and so couldn't find them).
UPDATE: I just figured out that I could've then just clicked on the red group or file, pressed CMD+i (Get Info from the context menu, which you can open by right-clicking on the red file or group), and under the General tab, clicked Choose, then found where I moved the file to in the filesystem. But, I didn't do that, here's what I did instead, which also works:
Then, I just highlighted all the red files in Xcode and pressed command + delete to delete the broken (red) references. Then, I right-clicked on the Group I wanted to add the files to (usually the same group), and clicked Add > Existing Files.... Then, I found the same files in the new spot on the file system. I kept "Copy items into destination group's folder (if needed)" unchecked, I checked the radio button "Recursively create groups for any added folders," and I checked add to target acani if the files I was adding were being used to build the acani iPhone app.
I did the above with like a directory of files at a time. A few times I was more aggressive, adding multiple directories at a time, since I almost always selected the radio button "Recursively create groups for any added folders."
I found out that the files acani_Prefix.pch and acani-Info.plist had to stay in the root file system dir (although there may be settings you can set to allow these files to be elsewhere, like I think you can add a line to acani-Info.plist so that you can move/rename acani_Prefix.pch, but I'm fine with them in the root dir on the file system.
That was annoying to do, and perhaps not even worth the trouble, perhaps procrastination, but going forward, before adding existing files to Xcode, I'll first make sure they're in the place I want them to be on the file system.
OK, so here is how it works:
Xcode doesn't know about any files until you tell it about them. That is, even if you add a file manually in the finder (usually a bad idea) to a folder that contains files in an Xcode project, it doesn't know about them until you "add existing file to project".
The best practice (imo) for adding an existing file (or group of files) to a project (say, some code you just downloaded) is to choose "add existing files" and then "copy items to destination group's folder (if needed)" in the next dialog, if you want your project to have a copy of the files in question, rather than merely a reference to them (there are advantages and disadvantages of both).
Don't worry too much about the naming of folders in Xcode, or where you put things, but try to keep to a standard that makes sense in your environment. For example, I always put the classes I write in "Classes", and have separate folders for any library code i've downloaded for use in the project. I always put images/icons/audio etc in to "Resources".
In short, if you like what's in the project folder to be approximately the same as what's in your project, always add existing files by choosing the "copy items to destination group's folder"
The flexibility in XCode is intentional. It's up to you to decide how you like to organise things.
Should I care at all? Should I just use the fake folders and let
everything go everywhere and not care? My application bundle will be a
mess, the filesystem will be a mess, but it will all work... I would
hope?
IMO no... :) basically. The whole point is that XCode has been designed to give you the best experience of programming. If Apple wanted you to physically organise all your files and folders within the actual filesystem then they would have made it that way.
I don't really understand why you would want to organise all the files and folders in this way anyway? It makes no difference to the running of the application and the "fake" folders (groups) in XCode adequately provide the necessary visual aid for yourself (and others) to navigate through your classes and other resources. Organising it correctly in your filesystem (as you have found) surely just makes things more difficult?
Use Synx.
It rearranges your files on disk to match your Xcode groups. I try to run it before committing any code that changes the Xcode groups, and it keeps the project nice and tidy.
It would be great if Xcode could keep itself and the file system in sync. Unfortunately it doesn't. One reason for wanting it to is so the hierarchy in your SCCS matches the one in Xcode.
I fall back to keeping things organized in Xcode, and leaving the file system separated into not much more than "Classes" and "Resources".
This changed with Xcode 9. From the release notes:
Groups in the Project Navigator are now more closely associated with
directories in the file system. (28612132)
Dragging files between groups in the Project Navigator moves the files in the filesystem and updates any associated SCM working copies.
When a group is connected to folder in the filesystem, creating, renaming, and deleting groups updates the corresponding files and
folders in the the filesystem.
To remove a connection between a group and a folder in the filesystem, select the group, and then open the File inspector and
click on the on the Clear path button (X).
To add or update an association from a file or a folder in the filesystem to a file or a group in the project, select the file or
group, open the File inspector, and drag the corresponding file or
folder onto the Location section in the File inspector.
The new behaviour is available from the 'New Group with Folder' command (which may appear as just 'New Group'), while the old behaviour is available from the 'New Group without Folder' command (which may also appear as just 'New Group'!) The dominant usage amongst any existing groups in the target folder seems to determine which command gets labelled 'New Group'. It's more than a little confusing, but if you are in the habit of choosing one or the other, the idea seems to be that you can just stick with the default 'New Group' command. (See rob mayoff's far more thorough explanation.)
What I do is create a group to represent each folder and then, before adding files to it, in the right panel, first tab, immediately below "Path", there is an icon that allows you to choose the folder. In that folder dialog, I create a folder that matches the group and choose it.
In xcode3, this resulted in new and add files dialogs starting in this path. That made it worth the effort. Xcode4, however, does not respect this setting. Therefore, its questionable whether there is any real value in it. I also wish XCOde would support better file system organization.
Considering that file names must be unique within a project, regardless of groups and folders, there is justification for accepting the flat folder structure default and using groups for IDE convenience. Its difficult to come from other platforms where this is frowned upon.
i feel you and personally cannot NOT care about the actual structure and just rely on workspaces.
what would be really great is a tool that will go over the workspace structure and re-organize the file system accordingly, taking care of any re-naming of folders etc. this would be a classic solution and IMHO should be implemented as an option as we re-organize our project as we move about it.
some issues could be source control though xcode4 works with both git and SVN.

Xcode File management. What is best practice?

I've been using Xcode for a while now. One thing that always bugs me is the way it handles files. I like to have my files all in nested folders rather than one big physical folder, but when you create a group in Xcode by default it does not create a folder just a virtual folder within the project.
I can see that virtual folders are great for linking code in arbitrary places into your project but once you get beyond a few classes I find the one big folder approach really painful. And then if you try to fix it later it takes ages and is easy to break your build.
Is it possible to change this behaviour so that by default it creates a physical folder? Or am I doing it wrong and trying to cling to some other way of working? How do other people work with files in Xcode?
1) Remove all the files from the project. Select All and press Delete, and click the Delete File References button, not the Also Move to Trash one.
2) Go to the Finder or Terminal and rearrange your files in folders to your heart's content.
3) Select all the top-level files and folders and drag them back into your project. When given the choice, choose Create Groups for Added Folders.
You'll now have a group hierarchy that follows the directory hierarchy on disk.
You'll need to make sure all the proper files get back into their correct build phases and targets. It's best to do this one target at a time in a multi-target project.

Resources