Automatically include newly added files when pulling from GIT - visual-studio-2010

User 1: creates a new class and commit and push that to git.
User 2: does a git pull. newly created class file gets downloaded but not included in project. Has to right click and do "Include in project"
Is there a way to automatically include a newly added file while doing pull from git?
Do I need to commit any other file (.csproj/.sln) to solve this issue?
IDE: Visual Studio 2010

The project files, .csproj, keep track of which files are loaded in a project. So yes, you will also need to commit the updated project file to the repository in order for User 2 to have the file added to their project as well.
In my experience, even if Visual Studio is open, it will recognize the changed project file and ask if you want to reload it. When you reload it, your project should have the new file loaded.
As an aside, there is a great blog post on why you should get fetch/merge instead of pull

Related

How do I change the name of a file?

In visual studio 2015 I changed the name of a file in my project (from test.ps1 to test.psm1). I saved my project. I committed the file (this is a git bitbucket repo) and pushed.
The filename in VS changed, but it did not change in the file system. If I view it in explorer its still called test.ps1. If I view it in bitbucket its called "test.psm1"!
What the heck happened and how do I do this right?
Edit:
OK so now I have a problem where modifying a file in VS is not reflected in the file system. Maybe I'm just misunderstanding how VS works?
I create a file in my project, or edit an exiting file and save and I don't see any changes on the file system.
If I commit and push I see those changes in my commits in bitbucket, why don't I see them on the file system?
Whats crazy is if I create a new file in VS I don't see it in file explorer, BUT if I open a PS console and do "Get-Item fullPathOfFileICantSeeInExplorer.ps1" it finds it! What the hell is happening?
Copy the problem file to another file system location and rename it.
Delete the problem file using Visual Studio from your project.
Add the renamed file to your file system location of where it was in your project.
Add existing file using Visual Studio and select the renamed file.
Finally, Commit.

New files using Visual Studio, Bitbucket and SourceTree are not added on project

I have an annoying problem with integration of SourceTree, Bitbucket and Visual Studio.When i create a folder, class or Reference in my project and pushed to bitbucket,they dont are automatically added to other project when pushed.They are in the folder but dont are added in project.I already looking for answers here in Stack Overflow but no one helps me.As you can see in image,the "Teste" folder are not included in my Visual Studio project.How figure it out? Thanks
Folder
Visual Studio Project
This probably happens because the files where not being included in .csproj , this could happens because the order of the git commit, you can change the order of the commit , or rebuild your project before the commit , this will automatically add the classes in .csproj
Also you can give some attention to the .gitattributes file to use a slightly different merge driver.
*.csproj -text merge=union
*.sln -text merge=union`
If you wanna read more about you can click Here.

Visual Studio: How to create project from existing GitHub repository?

I came from Eclipse background and I am apparently missing something.
There is an existing GitHub project with JS code in it and I would like to start adding TypeScript nature to it, one type at a time.
I have followed this tutorial to clone project from GitHub to my "local git repository". Now the Team Explorer window displays it as local repository and I can commit changes etc but it's not a project and I don't know how to open it as a project (I want to open it as TypeScript project).
The workflow I was used to from Eclipse would simply be New -> Other -> SVN -> Checkout Projects from SVN that is automatically followed by New Project Wizard.
How do I clone existing JS project from GitHub and make it a TypeScrip project while keeping the existing folder structure?
EDIT: I am using Visual Studio Express and I am limited to the native Git extension.
What I typically do in this situation;
Clone repository using Git in Visual Studio; or use GitHub for Windows and Clone in Desktop from the Git project's web page. This will create a directory (repository) with the project files where you specify.
In visual studio, File->New->create a new project from existing code. From the wizard, select C# or C++ (whatever your choice it does not really matter)
The wizard requires a project file location: give the location of the Git folder that contains the project files (where you cloned the project's repository).
The Wizard requires a unique project name, for example you can use the name of the Git project with VisualStudio (or VS) appended to the end.
Git will now be in sync and you will be able to see all the git files. Making changes will check them out and allow you to push them to the project etc...
***** By default Git will want to check in the newly created .csproj file that Visual Studio creates to allow you to open the project in Visual Studio. You will just want to drag this into the excluded changes section because most likely the project in question will not be using Visual Studio.**
I solved this by opening the site as a website. File->Open->Website.
No Project Files/Solution files required. It just opens up the folder in the solution explorer.
To make it a typescript project, just add a tsconfig.json file to the directory.
Do you have any code in that repository yet that you want to open? I'm guessing not in which case you need to create a new VS project (just like you'd create a new Eclipse project and have it in your workspace)
Go to File, New..., Project... and pick the project type that you want. Give the project a name and set the location to be a folder INSIDE the folder that you cloned your Git repo to earlier (i.e. c:\mycode\mygitproject). Also give your solution a name. A "Solution" in Visual Studio is a wrapper for the projects inside it, kinda like the closest thing to a workspace or a working set in Eclipse but not quite the same thing.
Then Visual Studio should then be smart enough to pick up that this is in Git repo and allow you to commit locally as well as push/pull to GitHub etc.
Finally, while I work with the team that created the Visual Studio Tools for Git, I'd still highly recommend that you get hold of a command line should you want to do some more powerful stuff with Git other than simply committing code, push/pulling changes and branching or merging branches. If you are working against GitHub then you might also want to install GitHub for Windows which will bring some Git tools with it or you can install Git for Windows and also install Posh-Git separately. All of these things work together and give you the maximum power of Git but you can pick and choose the tool that works best for you. You'll probably find a workflow of Clone using GitHub for Windows, commit/push/pull/branch/merge in VS and then Posh-Git if you do more advanced stuff or want to hand-tweak settings.

Programmatically update files in a tfs workspace

I am working on an extension for visual studio to update a project.
The situation is a follows:
We create a new project from a template.
We put the solution in tfs
We change the project which was used to create the template. The project on the tfs server still needs te be updated.
We publish the project to a folder. I now want to update the files in the TFS repo with the current files in the publish folder
I thought of the following approach:
In the application we have all the project stored that are on the TFS server. When I want to update a specific project I select the project from the database. Next I load this project from the TFS server and create a new checkout for this project. So far so good. The problem arise when I copy the files from the published folder to the new checkout. Files that are already registered in the workspace get marked as changed but the files that are new are not added.
The only solution I can think of is to add all the files through the TFS SDK. But this seems pretty heavy to me.
So I got a couple of questions:
Is this the right approach to update
the project?
Is there any other way to add the files to the workspace instead of adding all files through the TFS SDK?
Thanks!
Don't do a blind copy of the files. Instead, have your program iterate through them one by one.
First, update your workspace with the latest from TFS.
Then, for each file in the source directory:
If the file exists in the target directory, "pend edit" the file, then copy it.
If the file does not exist, copy the file, then "pend add" the file.
When you've finished, check in all pending changes in the workspace.

Visual Studio and TortoiseHg: folder not visible in VS

I created a C# project and added it to source control (mercurial). I can edit files in VS, commit it and push it using TortoiseHg. It goes to the server. When some one pulls they get the files.
In my visual studio I added a folder and a file inside that folder. I used TortoiseHg and it saw the new file in the new folder. I committed it and pushed it.
However, now someone pulled the latest code from the server - and they got the new file (it is visible through windows explorer), but when they open the solution in VS, they don't see the file.
Does someone have an idea what is wrong here? or things I should check? Thank you for the help.
P.S. I have visual studio 2010 express (so I can't use the VisualHg plugin).
Visual Studio caches changes to the solution and project until an explicit save or a build. In your comment:
In my visual studio I added a folder and a file inside that folder. I used TortoiseHg and it saw the new file in the new folder. I committed it and pushed it.
I see that an updated .sln or .vcproj file was not mentioned and checked in. Did you see an update to either of these files via TortoiseHg? If not, make sure to build or save your project after a change like this.
Did you make sure that the Visual Studio Project File or Solution file is being updated and committed?
VS solution contains projects and each project select managed files by metadata(***.vcproj file). It's not the way include all files from root directory.
So, your co-workers can see new added files by in following two ways.
1) share project file(***.vcproj)
2) manually add files in each person's VS instance.

Resources