将代码上传到VSTS团队项目

问题描述 投票:0回答:1

有没有选择将代码(从zip文件)上传到空的VSTS团队项目?我已经使用VSTS API(Projects)来创建团队项目,但我没有看到任何选项将代码推送到新创建的VSTS项目。

我们可以从Visual Studio连接到团队项目并检查代码,但我正在寻找一些可以添加代码来清空VSTS项目而无需人工干预的流程。

任何帮助/指针将不胜感激。

azure-devops-rest-api
1个回答
1
投票

首先,您应该在空文件夹中解压缩zip文件。然后提交并将文件推送到新创建的仓库中。

Uncompress zip file:

string zipPath = @"C:\a\1.zip"; \\zip file you want to uncompress
string extractPath = @"C:\a\2"; \\empty path to extract files in zip
ZipFile.ExtractToDirectory(zipPath, extractPath);

Add the uncompress files into git repo:

对于git repo

您可以将REST API用于add files and push to git repo

或者你可以使用System.Diagnostics.Process来执行git命令,例如

ProcessStartInfo gitInfo = new ProcessStartInfo();
gitInfo.CreateNoWindow = true;
gitInfo.UseShellExecute = false;
gitInfo.RedirectStandardError = true;
gitInfo.RedirectStandardOutput = true;
gitInfo.FileName = @"path to git.exe"; \\such as D:\program files\Git\bin\git.exe
gitInfo.Arguments = "git remote add origin https://account.visualstudio.com/project/_git/repo";
gitInfo.WorkingDirectory = @"C:\a\2"; \\path where extract files in

Process gitProcess = new Process();
gitProcess.StartInfo = gitInfo;
gitProcess.Start();
string stderr_str = gitProcess.StandardError.ReadToEnd();  
string stdout_str = gitProcess.StandardOutput.ReadToEnd(); 

gitProcess.WaitForExit();
gitProcess.Close();

对于TFVC回购

你可以使用the commands

© www.soinside.com 2019 - 2024. All rights reserved.