Question

i have creating a console application which takes the two argument one as input .xml file and give output as .htm file

below is code for the accessing tfs

TfsTeamProjectCollection teamProjectCollection =
                TfsTeamProjectCollectionFactory.GetTeamProjectCollection
                (new Uri("http://myServer:8080/tfs/defaultcollection"));

            var buildService = (IBuildServer)teamProjectCollection.GetService(
                                                 typeof(IBuildServer));

IBuildDefinition myBuildDefination = buildService.GetBuildDefinition(
                   "MyProjectName", "MyBuildDefinationName");
            Uri lastKnownGoodBuild = myBuildDefination.LastGoodBuildUri;
            IBuildDetail myBuildDetail = buildService.GetBuild(lastKnownGoodBuild);
            string dropLocation = myBuildDetail.DropLocation;

but above doesnt seem to be working for me...so i thought to manually pass the path. as you can see in below code snippet

// i have just added blackslash at the start and my problem solved
    string xmlfile = "\\\\myTfsPath\\CodeMetricsResult.xml";
     if (File.Exists(xmlfile))
     {
          //do something
     }

but for some reason...it always go to my else block.

please let me what i am doing wrong

note....the tfs path is on network and i have all the access to it.

thanks,

Était-ce utile?

La solution

The latter part should work for a complete input that points to an existing file @"C:\Folder\CodeMetricsResult.xml"
That's valid even for files in your network @"\\netdrive\Folder\CodeMetricsResult.xml"

I tried your snippet that uses the TFS-SDK and it worked fine. Some hints:

  • Ensure that http://myServer:8080/tfs/defaultcollection is correct by right-clicking on the root of your TeamCollection in Team Explorer, select 'properties' and check that the entry under 'Url' matches.
  • Check that MyProjectName matches the exact name of your TeamProject and MyBuildDefinationName your build definition name.
  • Right-click MyBuildDefinitionName under 'Builds' and select "Edit Build Definition". Navigate under "BuildDefaults" and check that "This build copies output files to a drop folder".
  • Check that the last succeeded build of MyBuildDefinionNameis still persistent (= hasn't been deleted). In order to do this right-click it on TeamExplorer, select "ViewBuilds" and find it in the Build Explorer that pops up. Once you do find it, click "open drop folder" in the build summary, to ensure that TFS has kept it.
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top