Reconnect Visual Studio project to GitHub repository - c#

I've had to reformat my hard drive. I've restored my Visual Studio projects but now I need to reconnect them to their corresponding GitHub repositories.
Unfortunately, information about that connection does not appear to have been saved with my projects.
How can I re-establish the connection between my project and the GitHub repository? Preferably, without having to recreate everything or lose any work.
I have a lot of projects I will need to reconnect to their repositories.
Note: I'm just using build-in Visual Studio commands to manage my repositories.
Note 2: I added one project to source control and it now shows every file as being added. I'm not sure if this was a mistake.
Update:
So, I added my project to source control, and tried to publish the project to GitHub. I think this overwrites everything and I lose all my current history. But I'm not seeing other options. But this gives me an error.
Error encountered while pushing branch to the remote repository: rejected Updates were rejected because the remote contains work that you do not have locally. This is usually caused by another repository pushing to the same ref. You may want to first integrate the remote changes before pushing again.
But the Pull command is disabled and says The current branch does not track a remote branch.

In order for the solution to remember your GitHub settings, you need to save the hidden .git folder.
My regular backup procedure did not copy this folder, although I was able to retrieve the old one.
Since I had re-added the project to source control, I could easily undo this by deleting the new .git folder. And I was able to copy of the original .git folder in its place. And when I loaded the project, all the repository settings were as they were before and Visual Studio recognized any new changes I had made.

Related

Unable to compile repository downloaded from server

I created a source code repository with a branch, the source and branch are working fine, checking for pending changes everything went up to the repository with no problem.
It is assumed that uploading everything to the repository without problems should download without errors, but when a team member gets the project from the server, it fails to compile.
Mistakes go through this:
Why when obtaining the project some dlls are not loaded?
This is the repository you create with TFS (Azure DevOps).
How can I force that when downloading the repository it downloads with all the dlls?
On laptop everything works fine, this happens when someone else gets the project from server.
No sure how you add those reference into your project.
But if you do use nuget, then just simply restore the nuget packages
Right click on your solution
Click on Restore NuGet Packages

Where is Visual Studio storing Publish Profiles?

I have a corrupted Publish profile.
I need to delete it. My other computer is fine, so I know it is local.
I have tried:
Clean checkout of codebase from Git (so nothing is local in my code directories).
Deleting C:/Users/<user>/AppData/Local/VisualStudio
Deleting C:/Users/<user>/AppData/Roaming/VisualStudio
Full text search of Profile Name 'MunicipalAgenda' through Registry
Full Text search through machine.
Creation of a new Windows User for Visual Studio Development.
Despite all of this, VS.NET is hanging onto that corrupted Publish profile.
Honestly I am at wits' end, and my next drastic step is to do a fresh reinstall of Windows 10. Please help before it comes to that!!!
Normally any publish profile store in particular project.
For that you have to look at following location.
Go to that project.
Project has special folder call Properties
Inside that there is a folder called PublishProfiles ( Something similar)
I also had some difficulty in getting my profile deletions to stick ... Visual Studio (2017) doesn't seem to be able to do it from Solution Explorer.
My latest attempt is to go to Source Control Explorer, open up the /Properties/PublishProfiles folder, and delete and commit the unwanted profiles from there. So far so good :)

Visual Studio not seeing all my files after git pull

I am working on a C# project from 2 computers. I made changes from one of the computers and committed the changes and then pushed them to gitHub. On my other PC I pulled the changes using git pull command.
Now I can see the new files added to the project in windows explorer. but visual studio doesn't see them for some reason.
I even deleted the whole project on the second computer and cloned the project again but that didn't help.
What am I missing? is this related to VS project settings?
Likely your changed project file was not saved or not committed. Check the commit has changes to the .csproj file. If not, save the changed project file, and make a new commit.
I have been bitten by this a few times, and now mash ctrl-shift-s (save all) in VS before committing.
Such of hundreds of problems:
Close solution and reopen it!
It

Issue with Visual Studio Community 2013 and Git

I just noticed the files I created (.cs, .xaml, etc) are not added to Git, so my commits+push wont upload them to the repository. I know I can go to the terminal and do git add path/to/file but I want to know how can I do this from within Visual Studio.
I tried right-click the file and search for Add to source control but the option is not listed. What do I do?
I already looked it up but every Microsoft documentation is for Team Foundation and it doesn't work for me
Make sure Microsoft Git Provider is selected as your Source Control plugin (assuming Visual Studio 2013):
In Visual Studio, on the Tools menu, click Options.
In the Options dialog box, click Source Control, then click Plug-in Selection.
Select the source control plug-in that you want to use (Microsoft Git Provider).
Click OK.
Locks should appear next to your files (assuming your project is a git repository), and you should be able to add your files.
Reference: https://msdn.microsoft.com/en-us/library/axafab5c(v=vs.90).aspx
Edit: Since you already have your plugin set correctly, you likely just need to perform a commit. I don't believe Visual Studio has a seperate interface for staging changes; when you go to commit, it should list your new files as "Included Changes", and the file should have a green plus next to it in the Solution Explorer.
Any files that aren't being committed should be listed under Excluded Changes or Untracked Files below that. You can add individual files to the commit from here.
If your file is missing the green plus, I'd check your .gitignore file to ensure it's not being ignored.

Visual Studio restoration of Nuget packages through TFS

Today I ran in to a problem that took me a little while to figure out because of my apparent misunderstanding of how the Enable NuGet Package Restore worked within source controlled projects in TFS. So to start out with let me explain the issues that I have spent the last week or so troubleshooting.
On our TFS server, I created a build definition for continuous integration. When the source code is checked-in, the build server begins compiling the source and then fails due to not being able to fetch NuGet packages. I thought initially that it was due to Enable NuGet Package Restore being disabled, so I switched it on at the solution level and re-committed my code. The builds continued to fail. Without having admin access to the Virtualized Instance of the build server, and the admin being swamped lately I let moved on and decided I'd deal with it in a couple of weeks when my Sprint and his Sprint lightens up. Getting the build server up and running is not a must at the moment. I did however remove my local mapping to the branch in TFS, delete the local directory, re-map the source code and perform a fresh get and re-compiled the source without any problems. The NuGet packages downloaded just fine.
Today however we had a new-hire join the team. He pulled a fresh copy from TFS and encountered some SlowCheetah (for transforming our WPF App Configs) NuGet failures. We spent a good chunk of time today trying to figure out why his wasn't pulling down the files properly. After a little while, I right clicked on his solution and noticed that the Enable NuGet package Restore option was available. Even though on my solution, I had enabled it, his solution did not have it set up. I enabled it and immediately his solution compiled without error.
So now down to the primary question, if I enable the solution to restore packages why do I have to re-enable it on another box? I was under the assumption that by making sure Allow NuGet to download missing packages during build option is enabled in settings on all of the boxes, Visual Studio would automatically download the NuGet packages missing from my TFS source code. This confuses me and I would appreciate some clarity on how NuGet should work (and be restored) when packages are used in a project stored in TFS. We are not including any of the packages with our TFS check-ins because I though this feature was supposed to automatically work for the project.
Lastly, I am wondering if this is why my build server is failing to run my build definition. I am getting the NuGet errors and am not sure how to tell the build definition to download the NuGet packages. Is this something I need to do by modifying the build template, adding a sequence to download NuGet packages prior to running MSBuild or something?
Thanks in advance.
Edit 1 I would like to also mention that the NuGet .targets file is included in the TFS branch as well.
This is called Package Restore Consent and for the IDE you need to do it per user. There is a way to override per machine, but its easier per user.
For servers you can use the EnableNuGetPackageRestore environment variable with a value of 'true'
Find out more on: http://docs.nuget.org/docs/reference/package-restore

Categories

Resources