forked from KirillOsenkov/MSBuildStructuredLog
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Common.targets
85 lines (74 loc) · 3.38 KB
/
Common.targets
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<NuGetExePath>$(SrcRoot)NuGet.exe</NuGetExePath>
<NuspecPath>$(MSBuildProjectDirectory)\$(NuspecFileName).nuspec</NuspecPath>
</PropertyGroup>
<ItemDefinitionGroup>
<NuGetInput>
<Visible>False</Visible>
</NuGetInput>
</ItemDefinitionGroup>
<ItemGroup Condition="'$(NuspecFileName)' != ''">
<NuGetInput Condition="Exists('$(NuspecPath)')" Include="$(NuspecPath)" />
<NuGetInput Include="$(MSBuildThisFileFullPath)" />
</ItemGroup>
<Target Name="ExtractVersion"
AfterTargets="CoreBuild"
Condition="Exists('$(NuspecPath)')"
DependsOnTargets="PrepareResources;GenerateAssemblyVersionInfo">
<PropertyGroup>
<NupkgPath>$(OutDir)$(NuspecFileName).$(Version).nupkg</NupkgPath>
</PropertyGroup>
</Target>
<Target Name="BuildNuGet"
AfterTargets="ExtractVersion"
Condition="Exists('$(NuspecPath)')"
DependsOnTargets="ExtractVersion;_DownloadNuGet"
Inputs="@(NuGetInput)"
Outputs="$(NupkgPath)">
<Exec Command="$(SrcRoot)NuGet.exe Pack $(NuspecFileName).nuspec -BasePath $(OutDir) -OutputDirectory $(OutDir) -prop currentVersion=$(Version)" />
</Target>
<Target Name="SquirrelReleasify"
AfterTargets="BuildNuGet"
Condition="Exists('$(NupkgPath)')"
DependsOnTargets="BuildNuGet"
Inputs="$(NupkgPath)"
Outputs="$(OutDir)Releases\MSBuildStructuredLogSetup.exe">
<Exec Command="$(NuGetPackageRoot)\squirrel.windows\1.4.0\tools\Squirrel.exe --releaseDir=$(OutDir)Releases --no-msi --releasify $(NupkgPath)" />
<Copy SourceFiles="$(OutDir)Releases\Setup.exe" DestinationFiles="$(OutDir)Releases\MSBuildStructuredLogSetup.exe" OverwriteReadOnlyFiles="true" SkipUnchangedFiles="true" />
<Delete Files="$(OutDir)Releases\Setup.exe" />
</Target>
<Target Name="_DownloadNuGet">
<DownloadNuGet OutputFilename="$(NuGetExePath)" Condition="!Exists('$(NuGetExePath)')" />
</Target>
<UsingTask TaskName="DownloadNuGet" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll">
<ParameterGroup>
<OutputFilename ParameterType="System.String" Required="true" />
</ParameterGroup>
<Task>
<Reference Include="System.Core" />
<Using Namespace="System" />
<Using Namespace="System.IO" />
<Using Namespace="System.Net" />
<Using Namespace="Microsoft.Build.Framework" />
<Using Namespace="Microsoft.Build.Utilities" />
<Code Type="Fragment" Language="cs">
<![CDATA[
try
{
OutputFilename = Path.GetFullPath(OutputFilename);
Log.LogMessage("Downloading latest version of NuGet.exe...");
WebClient webClient = new WebClient();
webClient.DownloadFile("https://dist.nuget.org/win-x86-commandline/latest/nuget.exe", OutputFilename);
return true;
}
catch (Exception ex) {
Log.LogErrorFromException(ex);
return false;
}
]]>
</Code>
</Task>
</UsingTask>
</Project>