Skip to content

Commit 8bfe7a1

Browse files
authored
Implement GoZipTool as NoTargets csproj (#4463)
1 parent e1e1817 commit 8bfe7a1

File tree

4 files changed

+61
-0
lines changed

4 files changed

+61
-0
lines changed

Azure.Functions.Cli.sln

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.Functions.Cli.TestFra
2525
EndProject
2626
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.Functions.Cli.E2E.Tests", "test\Cli\Func.E2E.Tests\Azure.Functions.Cli.E2E.Tests.csproj", "{D61226F6-3472-32C7-16F5-F07705F779CE}"
2727
EndProject
28+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GoZipTool", "src\GoZipTool\GoZipTool.csproj", "{7849148F-F156-4FAD-8087-3ADF22785A4B}"
29+
EndProject
2830
Global
2931
GlobalSection(SolutionConfigurationPlatforms) = preSolution
3032
Debug|Any CPU = Debug|Any CPU
@@ -63,6 +65,10 @@ Global
6365
{D61226F6-3472-32C7-16F5-F07705F779CE}.Debug|Any CPU.Build.0 = Debug|Any CPU
6466
{D61226F6-3472-32C7-16F5-F07705F779CE}.Release|Any CPU.ActiveCfg = Release|Any CPU
6567
{D61226F6-3472-32C7-16F5-F07705F779CE}.Release|Any CPU.Build.0 = Release|Any CPU
68+
{7849148F-F156-4FAD-8087-3ADF22785A4B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
69+
{7849148F-F156-4FAD-8087-3ADF22785A4B}.Debug|Any CPU.Build.0 = Debug|Any CPU
70+
{7849148F-F156-4FAD-8087-3ADF22785A4B}.Release|Any CPU.ActiveCfg = Release|Any CPU
71+
{7849148F-F156-4FAD-8087-3ADF22785A4B}.Release|Any CPU.Build.0 = Release|Any CPU
6672
EndGlobalSection
6773
GlobalSection(SolutionProperties) = preSolution
6874
HideSolutionNode = FALSE
@@ -77,6 +83,7 @@ Global
7783
{0333D5B6-B628-4605-A51E-D0AEE4C3F1FC} = {5F51C958-39C0-4E0C-9165-71D0BCE647BC}
7884
{3A8E1907-E3A2-1CE0-BA8B-805B655FAF09} = {6EE1D011-2334-44F2-9D41-608B969DAE6D}
7985
{D61226F6-3472-32C7-16F5-F07705F779CE} = {6EE1D011-2334-44F2-9D41-608B969DAE6D}
86+
{7849148F-F156-4FAD-8087-3ADF22785A4B} = {5F51C958-39C0-4E0C-9165-71D0BCE647BC}
8087
EndGlobalSection
8188
GlobalSection(ExtensibilityGlobals) = postSolution
8289
SolutionGuid = {FA1E01D6-A57B-4061-A333-EDC511D283C0}

src/GoZipTool/GoZipTool.csproj

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<Project Sdk="Microsoft.Build.NoTargets">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net8.0</TargetFramework>
5+
<ResolvedRuntimeIdentifier Condition="'$(RuntimeIdentifier)' != ''">$(RuntimeIdentifier)</ResolvedRuntimeIdentifier>
6+
</PropertyGroup>
7+
8+
<ItemGroup>
9+
<GoZipSource Include="gozip\**\*.go" />
10+
</ItemGroup>
11+
12+
<Target Name="SetGoZipPath">
13+
<PropertyGroup>
14+
<GoOS Condition="'$(ResolvedRuntimeIdentifier)' == 'win-x86'">windows</GoOS>
15+
<GoArch Condition="'$(ResolvedRuntimeIdentifier)' == 'win-x86'">386</GoArch>
16+
17+
<GoOS Condition="'$(ResolvedRuntimeIdentifier)' == 'win-x64'">windows</GoOS>
18+
<GoArch Condition="'$(ResolvedRuntimeIdentifier)' == 'win-x64'">amd64</GoArch>
19+
20+
<GoOS Condition="'$(ResolvedRuntimeIdentifier)' == 'win-arm64'">windows</GoOS>
21+
<GoArch Condition="'$(ResolvedRuntimeIdentifier)' == 'win-arm64'">arm64</GoArch>
22+
23+
<GoOS Condition="'$(ResolvedRuntimeIdentifier)' == 'linux-x64'">linux</GoOS>
24+
<GoArch Condition="'$(ResolvedRuntimeIdentifier)' == 'linux-x64'">amd64</GoArch>
25+
26+
<GoOS Condition="'$(ResolvedRuntimeIdentifier)' == 'osx-x64'">darwin</GoOS>
27+
<GoArch Condition="'$(ResolvedRuntimeIdentifier)' == 'osx-x64'">amd64</GoArch>
28+
29+
<GoOS Condition="'$(ResolvedRuntimeIdentifier)' == 'osx-arm64'">darwin</GoOS>
30+
<GoArch Condition="'$(ResolvedRuntimeIdentifier)' == 'osx-arm64'">arm64</GoArch>
31+
32+
<ExeSuffix Condition="'$(GoOS)' == 'windows'">.exe</ExeSuffix>
33+
<GoZipPath>$(IntermediateOutputPath)gozip$(ExeSuffix)</GoZipPath>
34+
</PropertyGroup>
35+
36+
<Error Condition="'$(GoOS)' == '' Or '$(GoArch)' == ''"
37+
Text="Unsupported runtime: $(GoOS) - $(GoArch). RID: $(ResolvedRuntimeIdentifier)" />
38+
39+
</Target>
40+
41+
<Target Name="BuildGoZip" Condition="'$(NoBuild)' != 'true'" Inputs="@(GoZipSource)" Outputs="$(GoZipPath)">
42+
<Exec
43+
Command="go build -o $(GoZipPath) @(GoZipSource)"
44+
EnvironmentVariables="GOOS=$(GoOS);GOARCH=$(GoArch);CGO_ENABLED=0" />
45+
</Target>
46+
47+
<Target Name="CollectGoZipOutput" DependsOnTargets="SetGoZipPath;BuildGoZip" BeforeTargets="AssignTargetPaths" Condition="'$(ResolvedRuntimeIdentifier)' != ''">
48+
<Message Importance="low" Text="Collecting GoZip output: $(GoZipPath)" />
49+
<ItemGroup>
50+
<None Include="$(GoZipPath)" CopyToOutputDirectory="PreserveNewest" />
51+
</ItemGroup>
52+
</Target>
53+
54+
</Project>
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)