locked
Error getting TFS environment variable RRS feed

  • Question

  • I'm trying to run a batch file called OnDemandVersion.bat as part of an On Demand build from this TFS directory:

    $/ABC/Development/Main/Src/Shared

    My batch file calls a C# executable that also exists in that directory. Since the solution (.sln) exists in the Src directory, I thought that directory would be the SourcesDirectory.

    I thought I could get to this directory by using the following steps in a sequence:

    1. Use a GetEnvironmentVariable<String> activity with this name:
        Microsoft.TeamFoundation.Build.Activities.Extensions.WellKnownEnvironmentVariables.SourcesDirectory
      and assign the result of that to a SrcDirectory variable I added as the Result of the activity.
    2. Use an InvokeActivity immediately after that with the following filename:
        System.IO.Path.Combine(SrcDirectory, "Shared\OnDemandVersion.bat")

    But when I run the build, I get the following error:

    TF215097: An error occurred while initializing a build for build definition \ABC\On-Demand_Main: Cannot create unknown type '{clr-namespace:Microsoft.TeamFoundation.Build.Activities.Core;assembly=Microsoft.TeamFoundation.Build.Activities}GetEnvironmentVariable({http://schemas.microsoft.com/winfx/2006/xaml}String)'.

    I also tried it without the GetEnvironmentVariable<String> activity and instead had this as the InvokeActivity filename:

    System.IO.Path.Combine(System.Environment.GetEnvironmentVariable(Microsoft.TeamFoundation.Build.Activities.Extensions.WellKnownEnvironmentVariables.SourcesDirectory), "Shared\OnDemandVersion.bat")

    But that didn't work either and gave me the following error:

    The build process failed validation. Details:  Validation Error: The private implementation of activity '1: DynamicActivity' has the following validation error:   Compiler error(s) encountered processing expression "System.IO.Path.Combine(System.Environment.GetEnvironmentVariable(Microsoft.TeamFoundation.Build.Activities.Extensions.WellKnownEnvironmentVariables.SourcesDirectory), "Shared\OnDemandVersion.bat")". 'Activities' is not a member of 'Build'.

    Which I don't understand since Intellisense says that Activities is definitely member of Build.

    Any suggestions?

    Tuesday, August 11, 2015 9:06 PM

Answers

  • Nevermind. I figured it out. ID10T error. Forgot to add the log4net DLL to the working directory.
    Wednesday, August 19, 2015 3:43 PM

All replies

  • Hi Micheal,

    Thanks for your post.

    What’s your TFS Version?

    Did you mean you add a GetEnvironmentVariable<String> Build Activity and an InvokeProcess Build Activity to custom your build process template? If yes, which build process template did you chosen to custom?

    You can share your custom Build process template snapshot here. And share the screenshot which displayed how to put your batch file in Build Definition here also.

    Best Regards,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place. Click HERE to participate the survey.

    Wednesday, August 12, 2015 7:27 AM
    Moderator
  • We're using TFS 2010

    Did you mean you add aGetEnvironmentVariable<String> Build Activity and an InvokeProcess Build Activity to custom your build process template?  Yes

    If yes, which build process template did you chosen to custom? I customized the a copy of the Default template.

    Here's a screen shot of where I inserted the activities:

    NOTE: I don't have access to the build controller so I need to accomplish my task without modifying it, if that's possible.


    Wednesday, August 12, 2015 2:39 PM
  • The XAML is apparently bigger than the 60000 character limit.
    Wednesday, August 12, 2015 2:42 PM
  •   

    Hello Micheal,

    I am trying to involve someone familiar with this topic to further look at this issue. There might be some time delay.

    Appreciate your patience.

    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place. Click HERE to participate the survey.

    Friday, August 14, 2015 6:21 AM
    Moderator
  • Thanks, Jessica. We're moving to TFS 2013 on Monday, so hopefully I'll be able to use some of its newer features to overcome my obstacle.
    Friday, August 14, 2015 5:22 PM
  • Hi Michael,

    How about your issue now? Do you still need further help for it?

    Thanks.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, August 17, 2015 8:34 AM
    Moderator
  • Hi Vicky:

    The changeover to TFS2013 went smoothly, and that error went away, but now I have a different one.

    In my Build -> Process -> Build -> Advanced Pre-build script, I entered this:

        $/Solution/Development/ABC/Src/Shared/VersionMaster.exe

    That executable references log4net.dll, which is in the same folder, yet I got the following error:

    Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'log4net, Version=1.2.13.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a' or one of its dependencies. The system cannot find the file specified.

    at VersionMaster.Program.Main(String[] args)

    Exception Message: TF270015: 'VersionMaster.exe' returned an unexpected exit code. Expected '0'; actual '255'. See the build logs for more details. (type UnexpectedExitCodeException)Exception Stack Trace:    at System.Activities.Statements.Throw.Execute(CodeActivityContext context)   at System.Activities.CodeActivity.InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager)   at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation)


    Any ideas what's going on?

    Thank you.



    Tuesday, August 18, 2015 2:50 PM
  • Nevermind. I figured it out. ID10T error. Forgot to add the log4net DLL to the working directory.
    Wednesday, August 19, 2015 3:43 PM