简体   繁体   中英

TFS Workflow MSBuild Activity Project Location

I like how BuildProcessTemplates and the Custom Assemblies folder automatically syncs build scripts onto the build controller/agent. I've written custom activities in C# and understand how to add an import so I can use the types in those assemblies.

I also see how it's possible to use an MSBuild file via the MSBuild activity. I also note that if I check an msbuild file (say foo.proj ) into the CustomAssemblies folder in source control that the msbuild shows up in the temp directory structure on the server along side my custom assemblies.

So here's my question? How do I reference the location of foo.proj in the MSBuild activity's Project property? I've been searching for variables and such but can't seem to put it together.

I've found a way to do it using a custom code activity. Basically I wire this up into the workflow as a variable initialization pattern and then later use it in my other activities. But I'd rather do it without the need for a custom assembly if possible.

using System.IO;
using System.Activities;
using System.Reflection;
using Microsoft.TeamFoundation.Build.Client;

namespace BuildTasks.Activities
{

    [BuildActivity(HostEnvironmentOption.All)]
    public sealed class FindCustomAssembliesDirectory : CodeActivity
    {
        public OutArgument<string> CustomAssembliesDirectory { get; set; }

        protected override void Execute(CodeActivityContext context)
        {
            context.SetValue(CustomAssembliesDirectory, new FileInfo(Assembly.GetExecutingAssembly().Location).Directory.FullName);
        }
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM