How do I make a graphical asset in Visual Studio update? - visual-studio-2010

I'm working on an XNA project and modify a graphical asset outside of Visual Studio. In order for those changes to show up in the application, I need to remove the reference to the original image, and then re-add the same image to see the changes. This happens whether I do a complete rebuild or not. Is there a way to streamline this process so that my project shows the changes I've made without having to remove the content reference and then re-adding it after each change.

XNA is pretty smart, and only wants to re-run assets through the content pipeline when it detects something has changed. For some reason it isn't seeing the changes you are making.
Make sure you are modifying the correct file. For example if your original image is at c:\myImage.png and your project is as c:\myGame when you add the image to the Content Project it gets copied to c:\myGame\myGameContent. Editing the image at c:\myImage.png wont get noticed. You need to edit c:\myGame\myGameContent\myImage.png
If you are editing the correct file and it still won't update, try touching another file. As smart as the engine is, it will run everything through the Content Pipeline when it detects 1 item has changed.* If that still doesn't work If you look at the top of the Solution Explorer there is a refresh button. Try pressing it as it should make sure your Solution Tree is in sync with the files on disk.
*note this is true for v3.1 it could have changed for 4.0

When you drag an item into a Visual Studio project (like, in this case, a Content Project), it will copy the file into the project directory. By default it does not reference the file you drag in (although that is available as an option).
(If the file you drag in is already in the project directory, it just leaves it there.)
The upshot of this is that you need to work on your content files in the content project directory, if you want to see your updates happen immediately.
If you don't know where the files are being copied to, select one of them in your content project and press F4 (properties window). Find the "Full Path" entry. That is where your files are stored.

Related

TFS source control - new files not automatically detected as pending changes

As per the tags, I'm using VS2013 and TFS2013.
There are multiple projects in the solution: Model, Presenter, View, etc. All other projects are working as expected in terms of source control operations.
Problems with the Model project:
Adding a new file via Solution Explorer isn't automatically detected as a pending change
Deleting a file isn't detected either
Other source control operations work fine for the Model project, such as:
Get latest version
Edit detection for existing files (including changes to the csproj
file when a new file is added)
Checking in pending changes
The csproj file would show up in pending changes with the newly added file listed in it, but the new file itself isn't showing up, therefore causing build errors on other developers' machines if only the csproj changes are checked in.
The workaround is to find the added file in solution explorer and Add via context menu, this will make it appear as a pending change. But this process should be automatic as per the other projects.
Noticed that there is no .vspscc file for the Model project while other projects have one each.
Any help appreciated. Thanks.
I would unbind and rebind the problem project and try again:
To unbind a solution or project from source control
In Visual Studio, open Solution Explorer and select a solution or
project to unbind.
On the File menu, click Source Control, then Change Source Control.
In the Change Source Control dialog box, click Unbind.
To bind a solution or project to source control
In Visual Studio, open Solution Explorer and select a solution or project to bind.
On the File menu, click Source Control, then Change Source Control.
In the Change Source Control dialog box, click Bind.
Select the database and location to which to bind, and click OK.
Click OK.
You might need to go to Advanced to find the Change Source Control option
https://msdn.microsoft.com/en-us/library/0eh3790h%28v=vs.90%29.aspx
Before unbinding and binding your solution try his:
Go to Source Control Explorer
Click the "Add Items to Folder" (the
one on the left of the red cross)
Select the items you want to Add and follow the instructions on screen
That's all
Click <Detected: x add(s), x delete(s)> : in the source control explorer then select the file to add
For years I've been relying on 'Detected Adds' to add missing files - which was never a sustainable solution but I've just about managed with it.
But now if broke.
I'm actually about to reinstall Windows but in the meantime one of the best ways I've found to get a sense on what's missing (and it's still working even though the detected adds isn't) is the recursive 'Compare' window.
You can add files from here too.
It's a little klunky but it gives me a good sense of security and shows file diffs if you want to see what may have changes.

Is there a way to recover erased code in a source-controlled project(TFS)?

I'm working on a project in Visual Studio 2012, that's hosted on TFS.Any way, I don't know if it's due to lack of sleep or sheer carelessness, when trying to move one large function body from one file to another, I copied the declaration to the new file, but forgot to copy the body and then erased the body from the old one, clicked save by reflex and closed the first .cpp file, so when I pasted it in the second one, to my surprised I pasted the declaration and not the definition.Undo pending changes would only undo the 'Add' alltogether.Is there ANY way to retrieve the lost source or should I start rewriting it ASAP?Because I spend quite a while writing it.
View the history of the file. Right click it >> Source Control >> View History, as below:
This obviously assumes you've checked it in at some point.
Under Visual Studio you have several levels of Copy / Paste, so you could have retrieved it by pressing CtrlAltIns (if I remember well).
If you still haven't closed Visual Studio, it might still be in your Copy / Paste ring, it might be worth giving it a try.
Otherwise, you can always rollback to a previous check-in state in your TFS server (if you checked in the code you want before you deleted it).
First, check-in your current state to the server. Then rollback to the previous version that had your code (right click your solution, then Source Control -> Get Specific Version). Now copy your code in a side editor. Re-go to the latest version (Get latest Version... on your solution). Now re-paste your code at the right place and you're done.
If CTRL+Z doesn't work inside VS, go to the empty folder of the deleted files and try CTRL+Z there. Has worked for me several times.

Word files disappear from "Solution Items" in VS2010

I've run into a problem with VS2010 (it also exists in the latest version, SP1 (10.0.40219.1)):
Add an existing Word file to the "Solution Items" and check this new file in.
Check the file out for editing
Double click on the file and edit it in Word (just make some minor changes)
Save the file (CTRL-S)
Now the file is removed from the "Solution Items" in Visual Studio (you may have to repeat the editing and saving a couple of times)
Update: I'm using Visual SourceSafe 2005.
Despite my research efforts I haven't really found anything on this issue apart from this Microsoft page, and I'd like to know whether there is a way to prevent this problem from happening.
Any ideas are more than welcome, thanks in advance.
G.
After further investigation I think I found the reason behind this behaviour and a workaround.
Please also note that the behaviour described in the original question only occurs for files that are added directly underneath a solution or to a folder that is directly underneath a solution.
The reason
I'm not sure whether the following is 100% correct, but the main point is how Word (and probably other MS Office apps as well) saves an existing file:
Save the current version of the file to a temporary file
Rename the original file so it can be used later in case something goes wrong
Copy the temporary file to the location of the original file, using the original file's name
Delete the original file (that was renamed in step 2)
Visual Studio picks up that the file doesn't exist (for a very short time though) and removes it from its tree and the .sln file. This can also be reproduced by manually adding any kind of file, checking it out (if not checked out), renaming it to a different name and then back to its original name => file is no longer shown in Visual Studio.
The workaround
I've created an empty project template following the steps on Microsoft's site. I also set the output to "Class Library" so that the project would compile even if no static main method exists. This template can be used to add a "Documentation" project to an existing solution. Underneath this project you can add files and edit them as you wish, as Visual Studio behaves differently and does not remove the file when it is saved in this constellation.
Obviously this approach is still not very satisfying or elegant, but I hope that it may be helpful for others who might run into the same problem.
G.
I've run into the same issue. I simply undo changes for the solution after I've closed the document file and the solution files will be as they originally were before your document changes.

Why can't I delete files from my XCode project?

This is probably a very easy question, but I'm having trouble deleting resources from my XCode project. I added them using "Create Folder References for any added folders" so that I could import a whole offline HTML site with its correct folder structure.
Unfortunately, now it has been added like this I don't seem to be able to delete individual files in the structure (it's not available from the Edit menu).
Can anyone help please? Thanks!
That isn't how folder references work. The idea is that its only a reference, you can open files within it and save it from those editors, you can delete or move the entire reference throughout the xcode project, but you can't actually edit it - its read only as far as xcode is concerned. Likewise, you cannot restructure it (move internal files around).
I'm not to sure why apple decided to make this the case, but apparently they have.
If you want to know how one might use the xcode folder system, here's how I tend to use them with my projects:
Whenever I subdivide code into folders, when I drag them into my project I click "recursively create groups for any added folders". If you do this, you any changes you make within xcode will not reflect the actual file itself. As far as I know, there is no way to do this. What does happen then is that when you add a new code file to it, the directory starts off in that file by default. ie, you don't need to navigate to it manually when you create a new file.
I use folder references whenever I'm working with content for an application I'm using. This way, I add all my images, folders, configuration files, whatever - and xcode immediately lists them. The reason I have it within xcode, I can I copy the files into the executables directory by dragging the folder reference into a "Copy Files" build phase.
Thats basically (to my knowledge) how one uses the folder types within xcode - sadly, I don't know how to achieve the functionality you want. You may have to manually delete the folders in finder, which if you do use folder references will update xcode to the change.
I ran into the same issue by using "Create Folder References for any added folders". I wanted to change some of the times but that's not possible. I had added a main folder that had other directories under it. I just had to select the main directory and deleted it and then just add the subdirectories that I needed. You can't make any location or removal changes to the directories that are added this way. -- Jeff
In the project browser, where you're looking at files, right click and choose "Delete". It'll prompt you to either remove the file from the project (leaving the underlying file on the filesystem) or to also move the underlying file to the trash.
I ran into the same issue. Delete the files from the folder directly as opposed to from within Xcode. You'll see the entries turn red under your project. Restarting Xcode should make these red entries vanish.

xcode copying project to another computer

I'm having problems copying a project over from one mac to another. The project compiles and runs fine after being copied, however xcode seems to have some duplicate of the same classes which seem to be invisible on the project browser on the left.
For example if I jump to definition on a variable I get 2 suggestions pop up. The top file when I look at its properties is relative to xcode folder (this is also the one that shows up in the class browser to the left). The second file which cant be seen on the browser has absolute path type in the properties.
Is there any way to get rid of this behaviour so its just looking at one file only like it originally was doing on the other mac? Its a bit problematic as I am never sure which one I am editing and they don't seem to update each other even though they appear to be the same file.
On a side note if I copy the copied project to another location then I get 3 etc files pop up in the jump to definition.
It's usually a good idea to either not copy the "build" folder (or delete it after you've copied everything over - only do this when Xcode is not running though).
Ok so what you need to do is this:
1.Duplicate your project.
2.Open the copy w/the original ,but only the folder.
3.open the Projects files(not the tests the main files)
4.then Drag and drop the files into the xcode area.
5.Zip the folder and its done
its like that because it just removes the references but not the files they are all still there though so just add the references back into the file.

Resources