0

I want to use macros of current csproj such as ${TargetPath} $(TargetName),in vNext Build defination as part of vs build task property of MSBuild argument,to do some copy etc.

But I found it not work,in build log, the macros did not be change into the absolute path.

Is there any way to use these macros just like in csproj post-build event?I did not find description about this on msdn ,and I could not use it in each csproj,because we have more than one thousand project files, edit the prj file one by one is not good:(

Thanks alot for your help.

Update

I want each project only output its own assembly without any referenced assembly when build.But I can't change project file to modify the reference property "copy local" to false.

Allen
  • 569
  • 9
  • 22
  • What's the purpose of macros with the ${TargetPath} $(TargetName)? Is it the same with the msdn link: https://msdn.microsoft.com/en-us/library/c02as0cs.aspx? If so , why you want to use this in the MSBuild argument not in the project's Property Pages? – PatrickLu-MSFT May 03 '16 at 10:35
  • @Patrick-MSFT Thanks for your help. Yes, the macros I mentioned is the same with your link.I use it in build task config rather than project property pages because there are some reference rule in our system.We separate each module into Interfaces and implements,and we settled them into diff project,only interface assembly can be reference between modules. When build,we output them into diff dir,if referenced others implement ,build will be failed.I use ${TargetPath} to copy dll of current csproj into correct dir,but did not include referenced other dlls. – Allen May 03 '16 at 15:26

2 Answers2

0

You just need to add it as MSBuild arguments: enter image description here

Eddie Chen - MSFT
  • 29,708
  • 2
  • 46
  • 60
  • Thanks,But What's the different between TargetPath and Output Path? Does it copy all referenced assembly to this Targetpath? – Allen May 14 '16 at 15:45
  • @Allen When you add the reference to your project, set the "Copy Local" property of the reference to "True", then it will be copied during the build. – Eddie Chen - MSFT May 30 '16 at 07:26
  • Thanks a lot. The property you mentioned “copy local”is not what I want. Because in There is Different between develop's environment and build env.Developer's local env, output path is used as Unit Test Path, they need copy local is true.but in build Agent env, build result need this property to be false. – Allen May 31 '16 at 03:44
0

If you mean you want to achieve the function in post-build event same as this question Visual Studio Post Build Event - Copy to Relative Directory Location. There is no such thing like post-build in vnext build.

You can add several steps to copy the assemblies (One step for one project) and specify the copy root in the step.Refer to this question Copy one file in target directory on deploy from visual studio team services However, as you have mentioned there are thousand project files. You can create a powershell script and add it in the build definition to copy the files.

Community
  • 1
  • 1
PatrickLu-MSFT
  • 49,478
  • 5
  • 35
  • 62