Skip to content

Instantly share code, notes, and snippets.

@lennybacon
Created June 16, 2017 14:04
Show Gist options
  • Save lennybacon/369a155cf23f7c3bcb7d40f1af33e3a2 to your computer and use it in GitHub Desktop.
Save lennybacon/369a155cf23f7c3bcb7d40f1af33e3a2 to your computer and use it in GitHub Desktop.
MsBuild property with the latest version of a file
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<NugetFixUpTaskPaths>$([System.IO.Directory]::GetFiles("$(UserProfile)\.nuget\packages\nugetfixuptasks", "*.targets", SearchOption.AllDirectories))</NugetFixUpTaskPaths>
<LatestNugetFixUpTaskImport>$(NugetFixUpTaskPaths.Remove(0, $([MSBuild]::Add( $(NugetFixUpTaskPaths.LastIndexOf(";")), 1 )) ))</LatestNugetFixUpTaskImport>
</PropertyGroup>
<Import Project="$(LatestNugetFixUpTaskImport)" />
<Target Name="Build">
<Message Text="LatestNugetFixUpTaskImport: $(LatestNugetFixUpTaskImport)" />
</Target>
</Project>
@lennybacon
Copy link
Author

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