Skip to content

Instantly share code, notes, and snippets.

@amis92
Created June 26, 2018 09:46
Show Gist options
  • Save amis92/c3eec8aa38ec562e4874215f09934782 to your computer and use it in GitHub Desktop.
Save amis92/c3eec8aa38ec562e4874215f09934782 to your computer and use it in GitHub Desktop.

Code listing from blog post:

<PropertyGroup>
  <TempFolder>$([System.IO.Path]::GetTempPath())$([System.Guid]::NewGuid())</TempFolder>
</PropertyGroup>
<Target
  Name="CopyTaskAssemblyToTempFolder"
  BeforeTargets="BeforeBuild">
  <Copy
    SourceFiles="$(MSBuildThisFileDirectory)MyCoolAssembly.dll"
    DestinationFolder="$(TempFolder)"
  />
</Target>
<UsingTask
  TaskName="MyCoolAssembly.MyCoolTask"
  AssemblyFile="$(TempFolder)\MyCoolAssembly.dll"
/>
<Target
  Name="MyCoolTarget">
  <MyCoolTask />
</Target>
@amis92
Copy link
Author

amis92 commented Jun 26, 2018

Could use Path.GetRandomFileName() instead of NewGuid for a shorter path

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment