Upload Project to Azure Devops - 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.

There are two ways provided by Azure DevOps that you can push your existing project to it.
Push the project from local VS and create a project in Azure Devops automatically at the same time;
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.

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

Related

Azure DevOps No Longer Showing in Visual Studio when Adding Project to Source Control

I recently updated Visual Studio 2019 to version 16.11.13. When I clicked Add to Source Control in the bottom right-hand corner, the option to publish the project to Azure DevOps in Team Explorer --> Synchronization no longer appeared. I've published Visual Studio projects to Azure DevOps this way for over 2 years now, and now I can't find a solution that works. Is there a setting that I'm missing that's not allowing me to publish to Azure DevOps?
Azure DevOps No Longer Showing in Visual Studio when Adding Project to Source Control
You could click the file and select clone repo:
we could add the new project to the local folder after we connect to the repo and clone the repo. Or we could copy the existing project to the local folder.
And you could do this from the team explorer.
Please check the document Enhanced Productivity with Git in Visual Studio for some more deyails.

How to change the repository location for a pipeline in Azure Pipelines

I have imported a repository from BitBucket to GitHub. How can I point the existing pipeline in Azure Pipelines to the new repository location? The UI has failed me so far.
Simplest way is to create a new pipeline, link it to the github repo and point it to the existing yaml file.
But there is a way to retarget the existing pipeline.
Edit the pipeline
In the upper right corner open the ... menu
Pick the ⚡ Triggers option
Click the YAML tab
Click the Get Sources option
Reconfigure the source repo

Looking for extension similar to GitLense for Azure DevOps

On my private projects I am using Git. I have installed GitLense for Visual Studio Code, which is awesome. I can click on a line, and see who changed it when within which changeset. See red arrows where I have deleted code and so on.
I have a VS2017 project using azure DevOps. I have read about CodeLense, which does not apply on my C++ projects, even in C# it is barely helpful.
Does someone know a similar extension here?
You could install the extension Code Compare to check the file changes.
Also, if you are using Azure DevOps and clone the repo local, we could open Team Explorer->Changes->Actions->View History->select commit and right-click->View Commit Details to check the changes, you could refer to this doc for more details.

File updated deployed, new file ignored

I create a web project with Visual Studio.
I use GitHub desktop app to push my code to my Github
I create an Azure DevOps project throught the Azure portal to create a CI and don't change anything
When I commit a change all the CI run, the build is done with success and a new deployment is done.
To be sure everything work I did 2 differents tests
First : I created a new HTML file in my project with the other HTML files. When I commit, build and deployment run on Azure Devops without error, but I cannot see my new file in the wwwroot folder
Second : I updated a existing HTML file. When I commit, build and deployment run on Azure Devops without error, and I can see my update on the file present on the web app.
Why this difference ? I would like understood why update work correctly but not the add. I don't know where start to troubleshoot the issue
Could you please check the "build action" of the new .cshtml file?
In visual studio, right click on the file and go to properties.
Check if the build action is set to "Content", if not set it to content and commit.
Other build actions sometimes will not show any error but the view file will not be copied upon build. This is not Azure DevOps issue, rather visual studio filetype issue.
Let me know if this was the case. Good luck :)

How do I move an Azure DevOps project to a different organization?

I have got a project in an old org (from VSTS), that I want to move to my new one.
I can't see any options in Azure DevOps on migrating projects, or any information on the interwebs.
Anyone know how to do it?
If you just need to move repos, you can use the built in clone functions:
Go to the Azure Devops source repo -> Files
Click "Clone"
Choose "Generate Git Credentials"
Create the target repo in the target Azure DevOps
Choose "Import a repository"
Use the URL and credentials from Step 3
Done
This is not supported today. But this feature was planned to develop: make it possible to move a Team Project between Team Project Collections
If your Azure Devops project only tracks code versions using a single Git repo, hence no boards, user stories, tasks, pipelines, etc. then you can do the following:
Clone your project repo.
For example with Visual Studio.
You don't need to clone if you already have a local repo.
Destroy the association with the remote.
For this typically, you need to open a command line prompt in the folder that contains the .git database folder, most likely the solution folder of Visual Studio and type git remote rm origin.
Here is an example using git bash showing the content of the solution folder, including the .git database and the *.sln Visual Studio solution file:
Open the solution with Visual Studio if not already done.
It should now show that you have many commits waiting to be pushed to a remote. For illustration purpose, my toy project only have 8 commits in total.
Click the up arrow and choose your new remote, say a brand new Azure DevOps project, in the organization of your choice, then push.
You are now done cloning the project in another organization. If needed, then destroy the project in the old organization to complete the "move" operation.
There are 3 projects that I know of to achieve this.
A paid for option by Ops Hub -
OpsHub Visual Studio Migration Utility
An open source tool that requires making changes to the work item process template - Azure DevOps Migration tools
An lastly an Unofficial but still written by Microsoft tool to create Azure DevOps project templates - Azure DevOps Demo Generator & extractor tool
With the last one (the Demo Generator) you extract the project as a template, then apply it to the new organisation. As it is a tool for demo's there is no support provided and in my experience it works for simple projects but falls over on anything complex.
Expanding on others' answers, this post regards Pipelines.
Azure DevOps API
Migrating nearly all aspects of a project across organizations is doable, but it is a lot of manual work using the Azure DevOps API. The link below shows you all the end points, variables, etc. From there you'll probably want to write a Power Shell script and do a couple test runs to a dummy Organization.
https://learn.microsoft.com/en-us/rest/api/azure/devops/?view=azure-devops-rest-6.1&viewFallbackFrom=azure-devops-rest-6.0
In App options
If you avoid the API, there is no way to migrate pipelines that preserve build or release history, but you can preserve your configurations and processes by going into your Pipelines and selecting View YAML. From here you can either take this away as notes to recreate the GUI steps in your new org/project location, or actually adopt the YAML standard in your git repository.
I do not believe there is a way to migrate pipeline variables outside of the API. However, you can move the variables to Azure Key Vault and change your pipeline settings (YAML) to reference values from key vault. This is not a large amount of effort and is a nice process improvement.
Lastly, if you have any locally installed pipeline agents for releases, you will need to run the Power Shell script for your new organization on the boxes. Very simple 5m step, but right now the Agent Pools are not sharable across organization.
As #Frederic mentioned in his answer, we can actually easily do it with Visual Studio. I have done this without Visual Studio. The steps involved are below.
Add a User to Both Organization
Configure SSH Key
Update the SSH Key in Source DevOps and Clone the Repository
Check out all the Branches and Tags
Update the SSH Key in the Destination DevOps
Remove Old and Add New Origin
Push all the branches
The commands and detailed explanations can be found here.
BTW, if you need to change the entire Devops Organization tied to your personal Tenant (E.g. VS Enterprise Subscription) and move it to new Tenant, you can change the AAD and point it to the new one e.g. your EA Tenant on Azure commercial cloud.
Before you switch your organization directory, make sure the following statements are true:
You're in the Project Collection Administrator group for the
organization.
You're a member or a guest in the source Azure AD and a
member in the destination Azure AD
You have 100 or fewer users in
your source organization. Otherwise you will have to open a support ticket.
You may have to add the users back in destination org if they do not exist becuase they will loose access the moment you switch the AAD.
you could just download as a zip file and then download it to the destination repo