-
Notifications
You must be signed in to change notification settings - Fork 467
Expand file tree
/
Copy pathCli.Build.targets
More file actions
40 lines (31 loc) · 1.75 KB
/
Cli.Build.targets
File metadata and controls
40 lines (31 loc) · 1.75 KB
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
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition="'$(Configuration)' == ''">Release</Configuration>
<OutputRoot Condition="'$(OutputRoot)' == ''">../../artifacts</OutputRoot>
<CliProject Condition="'$(CliProject)' == ''">src/Cli/func/Azure.Functions.Cli.csproj</CliProject>
</PropertyGroup>
<Target Name="BuildAndPackageCLI">
<Message Text="Building CLI for runtimes: $(RuntimeIdentifiers)" />
<!-- Split RuntimeIdentifiers into individual values -->
<ItemGroup>
<TargetRuntime Include="$([System.String]::Copy($(RuntimeIdentifiers)).Split(';'))" />
</ItemGroup>
<!-- Loop over each and invoke BuildForRuntime -->
<MSBuild Projects="$(MSBuildThisFileFullPath)"
Targets="BuildForRuntime"
Properties="Runtime=%(TargetRuntime.Identity)"
ContinueOnError="false"
BuildInParallel="true" />
</Target>
<Target Name="BuildForRuntime">
<PropertyGroup>
<OutputPath>$(OutputRoot)\$(Runtime)</OutputPath>
</PropertyGroup>
<Message Text="Publishing for runtime: $(Runtime)" />
<Exec Command="dotnet publish $(CliProject) -c $(Configuration) -r $(Runtime) --self-contained true -p:Version=$(Version) -p:InformationalVersion=$(InformationalVersion) -o $(OutputPath)" />
<!-- Zip output (cross-platform) -->
<Exec Command="powershell -Command "Compress-Archive -Path '$(OutputPath)\*' -DestinationPath '$(OutputPath)\func.zip' -Force"" Condition=" '$(OS)' == 'Windows_NT' " />
<Exec Command="zip -r 'func.zip' . " WorkingDirectory="$(OutputPath)" Condition=" '$(OS)' != 'Windows_NT' " />
<Message Text="Packaged CLI for $(Runtime) at $(OutputPath)\func.zip" />
</Target>
</Project>