2013-07-29 33 views
0

我正在创建一个程序来启动一系列项目的构建。我从启动Visual Studio 2010命令提示符的代码中调用一个批处理文件,并根据我选择构建的项目执行各种tfsbuild开始命令。我指定了以下参数:TFSBuild start/collection:http:// [myServer]:8080 // builddefinition:“myProject/myBuildDefinition”。执行批处理文件后,我得到以下错误,但我回到TFS中,构建开始并成功。tfsBuild在开始构建时抛出异常,但仍然构建

Unhandled Exception: System.NullReferenceException: Object reference not set to 
an instance of an object. 
    at Microsoft.TeamFoundation.Build.Client.InformationNodeConverters.GetBuildSt 
eps(IBuildInformation buildInformation) 
    at Microsoft.TeamFoundation.Build.CommandLine.CommandStart.build_StatusChange 
d(Object sender, StatusChangedEventArgs e) 
    at Microsoft.TeamFoundation.Build.CommandLine.CommandStart.Run() 
    at Microsoft.TeamFoundation.Build.CommandLine.BuildCommandLine.RunCommand(Str 
ing commandName, String[] args, Boolean& showExitCode) 
    at Microsoft.TeamFoundation.Client.CommandLine.RunCommand(String[] args) 
    at Microsoft.TeamFoundation.Client.CommandLine.Run(String[]& args) 
    at Microsoft.TeamFoundation.Build.CommandLine.BuildCommandLine.Main(String[] 
args) 

有人知道这个问题吗?我在调用tfsBuild时是否缺少一个参数?

[使用C#代码]

private void _buildButton_Click(object sender, EventArgs e) 
    { 
     if (_selectedProjectFolder.Equals("ProjectA")) 
      Process.Start(@"N:\Build batch files\ProjectA_Build.bat"); 

     else if (_selectedProjectFolder.Equals("ProjectB")) 
      Process.Start(@"N:\Build batch files\ProjectB_Build.bat"); 

     else if (_selectedProjectFolder.Equals("ProjectC")) 
     { 
      if (_build32RadioButton.Checked == true) 
       Process.Start(@"N:\Build batch files\ProjectC_Build_32.bat"); 

      else if (_build64RadioButton.Checked == true) 
       Process.Start(@"N:\Build batch files\ProjectC_Build_64.bat"); 
     }    
    } 

[批处理文件内容]

Call "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat" 
TFSBuild start /collection:http://[MyServer]:8080/ /builddefinition:"MyProject/MyBuild" 
+0

请张贴的代码。 – Isaiah4110

+0

我添加了我使用的代码。 –

+0

发布您正在调用BAT文件的整个C#代码/方法。我不认为这与bat文件或TFSBUILD启动命令有关。它在你的C#代码中。 – Isaiah4110

回答

0

此问题是由方法 “InformationNodeConverters.GetBuildSteps(IBuildInformation)”,当它是引起与更新版本的TFS服务器交谈。

请注意,Visual Studio Team System 2008团队基础服务器之后不再使用构建,并已用各种新信息节点类型(包括IBuildMessage,IBuildError,IBuildWarning和IActivityTracking)替换。其结果是,交谈运行新版本的服务器时,这种方法通常会返回一个空列表(例如,Team Foundation Server的2010)

http://msdn.microsoft.com/en-us/library/ff734692(v=vs.100).aspx

+0

谢谢,你认为在目前的状态下我能做些什么吗? –

+0

我假设你正在使用旧的VS2008构建定义吧?你可以在VS2010工作流中创建一个简单的构建定义,并从命令行调用它。我希望它不会抛出错误。 – Isaiah4110