0

I'm having the next problem:

I am trying to invoke a custom msbuild task from a .csproj file and I need to set a parameter (something like $(ProjectDir) ) indicating the TFS path that the project has mapped.

I don't know if it's possible or not; I couldn't find any macro in this link: http://msdn.microsoft.com/en-us/library/c02as0cs(v=vs.80).aspx

Just in case, this is the invocation from the .csproj file to my custom task:

<UsingTask TaskName="MyTask" 
         AssemblyFile="MyTask.dll"  />
<Target Name="AfterBuild" Condition=" '$(Configuration)' == 'Test' ">
    <DbBuildTask ConfigFile="$(ProjectDir)config\properties.config"
                 XPath="/configuration/properties/nhConnectionString" 
                 PathTfs="........" />
</Target>

Any ideas?

Thanks in advance!

Silvestre
  • 804
  • 11
  • 25
  • You are calling a MSBuild task and want to give a path to it, was this right? What task do you call? Usually the tasks have a specified set of arguments they accept, so giving additional arguments won't work. It would be like a call of a method using an additional parameter. I'm not sure why you want set ProjectDir, but I would expect to find somethign there. You can try to set the WorkingDirectory for the task call. – MikeR Feb 26 '13 at 07:19
  • It's actually a custom MSBuild task and I need it to receive the TFS mapped folder as a parameter. I imagine WorkingDirectory has the local path, but I actually need a variable that contains the TFS path. "$/TFSPROJECT/.../.../" – Silvestre Feb 26 '13 at 11:27
  • Is it a task you have written on your own or a 3rd party one? If it is a 3rd party one, you need to check if it accepts a parameter containing a path. It would be easier to understand if you could edit the call of the Task in your post. – MikeR Feb 26 '13 at 12:00
  • It is a custom activity of my own. Parameters to be configured is not the issue. Just in case: I added the call to the task in the post. – Silvestre Feb 26 '13 at 13:00
  • 1
    Thinking about it and reading again, it sounds like you need the TFS server path referencing the local file you know the path from, right? An example using API to workspace information `WorkspaceInfo wi = Workstation.Current.GetLocalWorkspaceInfo(Environment.CurrentDirectory); TfsTeamProjectCollection tfs = new TfsTeamProjectCollection(wi.ServerUri); VersionControlServer versionControlServer = (VersionControlServer)tfs.GetService(typeof(VersionControlServer)); Workspace workSpace = versionControlServer.GetWorkspace(wi);` – MikeR Feb 26 '13 at 13:26
  • Awesome @Mike! This did it for me: `var item = versionControlServer.GetItem()` Thanks a lot! – Silvestre Feb 26 '13 at 14:30

0 Answers0