user788448
user788448

Reputation: 797

Upload Project to Azure Devops

I am trying to push my existing visual studio project code to Azure Devops server (first time). All the tutorials start with create a new project on the AzureDevops and then clone to Visual Studio. Can anyone tell me how to push my existing project to server. Can I upload the files (including folders)? Thanks.

Upvotes: 9

Views: 36003

Answers (3)

Stokely
Stokely

Reputation: 15759

Add a Visual Studio 2022 Project to an Azure DevOps Repository

In 2023, this process is very easy to do now but sadly has very poor documentation online. Microsoft has updated Visual Studio 2022 with a much better user interface to help users integrate a local project from the IDE up to Azure DevOps.

No more silly Git commands. Yes!!

FIRST OPEN UP YOUR DEVOPS WEBSITE

  1. GO TO DEVOPS: First go to your Azure DevOps account: https://dev.azure.com/{your_organization}
  2. CREATE A DEVOPS PROJECT: Click "New Project", give it a name, scroll down and under "Advanced" choose "Git" for "Version Control", and click "Save". It will create a project but also a dummy Git repository with the same name as the DevOps Project. You will need to change its name to your Visual Studio 2022 project name. (FYI..."Git" is Microsoft's Azure Repos 'Git' product and replaces the old Team Foundation source safe model. It uses a proprietary form of Git that is stored in a SQL Server database on their Azure Cloud platform used by Azure Dev Ops. So, it works like Git and uses Git but its managed and stored differently.)
  3. CHANGE THE NAME OF YOUR REPO: In DevOps, open up the project you just created and in the lower left corner click "Project Settings". Scroll down and click "Repositories". A page appears to the right with your default repository listed. Click the three dots ... to the right and choose "Rename". Change the name of your repository in DevOps to match your Visual Studio 2022 solution/project name.. This will allow your to overwrite the DevOps empty repo with your own.

OPEN UP YOUR VISUAL STUDIO 2022 PROJECT

  1. In Visual Studio 2022, open up your project.
  2. Right-click the Solution for your project in the Solution Explorer
  3. In the context menu that appears look for either "Add Solution to Source Control" or "Create Git Repository".
  4. When you choose one the two items above a new window pops up in Visual Studio 2022 called Create a Git Repository. Choose "Azure DevOps" (instead of GitHub, the default) from the left menu. Then under it choose "Existing remote".
  5. The window should change and now show a box to enter the "Remote URL". This is where you will enter the Azure DevOps "Clone URL" that connects your Visual Studi0 2022 project with the Azure DevOps repository. enter image description here
  6. Go to your Azure DevOps website again, click the "Repository" menu, then choose your repo from the list. Look for the large "Clone" or "Clone Repository" button and copy the URL to the full DevOps path to your repository.
  7. Paste the URL above into the Visual Studio 2022 "Remote URL" field. Make sure it has the FULL URL PATH to your DevOps repository.
  8. The button "Create and Push" should no longer be grey now. Press it and it will upload your Visual Studio 2022 solution/project into DevOps and replace the empty repository with the same name on Azure DevOps! (If it asks to log into your Microsoft DevOps and/or Visual Studio accounts follow the prompts in Visual Studio 2022)
  9. YOU DID IT! You now have uploaded your local repo to the DevOps repo. Go to DevOps and click your repository and look at the files. You should see all your files uploaded and listed.
  10. You can now set up pipelines, do Git Push and Pulls from Visual Studio to DevOps, and run your CI/CD design in DevOps triggered by Visual Studio 2022 if you like.
  • This system works very well now with Devops and Visual Studio 2022. The key here is that you uploaded your repo starting at the solution folder that holds your solution file. This is critical as when you create pipelines or YAML files, they will appear in this same repo folder in Azure DevOps. So, after you create those YAML or pipeline settings files in DevOps be sure to go to your Visual Studio 2022 local project and "Pull" then down using Git in Visual Studio 2022's Team Explorer tab. The Visual Studio 2022 IDE now has beefed up tools to do push and pull Git commands for you with arrows and buttons in a simpler interface. You are now using Git in the IDE to communicate back and forth with your Azure Dev Ops repositories which is much simpler and faster now than stopping to type in commands.

Peace

Upvotes: 0

mbb5079
mbb5079

Reputation: 766

There are two ways provided by Azure DevOps that you can push your existing project to it.

  1. Push the project from local VS and create a project in Azure Devops automatically at the same time;
  2. Create a project in Azure Devops manually which I think you have already tried and then push your project in local VS to it.

Please follow this article for detailed information and also you can check below steps:

For the first situation, assume you have the project created already in your local VS:

a. Open your project in VS, click File in VS tool bar, click “Add to Source Control” in the menu and you will see in the little blue lockers beside your project files in Solution Explorer.

Add to Source Control

b. Open Team Explorer( you can find it in View in VS tool bar in case), click the small down arrow to open the menu, select “Sync”.

Sync

c. Now you can see the Synchronization menu, choose “Push to Azure DevOps” and click “Publish Git Repo”.

Push to Azure DevOps

d. Fill the form like below and then click “Publish Repository”. Now you can see a new project with the name in your Azure DevOps organization now.

Publish Repository

For the second situation, there’s difference in the step c, you have to choose the “Push to Remote Repository” and click “Publish Git Repo”, paste the HTTP code you can copy from your new created project in Azure DevOps – Repos. You can see it more clear in the article I provided.

Can I upload the files (including folders)?

Yes, any file and folder in your project will be pushed to Azure DevOps at the same time.

Upvotes: 9

Janusz Nowak
Janusz Nowak

Reputation: 2848

Flow the instruction when you create new project or new repository.

Pushing existing repository[1]

Upvotes: 0

Related Questions