Skip to content

Commit

Permalink
feat: Added global tool
Browse files Browse the repository at this point in the history
Currently, .NET cannot handle native packages.
So, this is WiP and still draft.
Fore details refer to dotnet/sdk#9503

First contribution for yoheimuta#337
  • Loading branch information
carstencodes committed Apr 9, 2024
1 parent 46989b2 commit 97fb2f6
Show file tree
Hide file tree
Showing 9 changed files with 188 additions and 0 deletions.
2 changes: 2 additions & 0 deletions bdist/dotnet/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
**/bin/
**/obj/
5 changes: 5 additions & 0 deletions bdist/dotnet/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<Project>
<PropertyGroup>
<ProtolintGoReleaserDistDir>$(MsBuildThisFileDirectory)/../../dist/</ProtolintGoReleaserDistDir>
</PropertyGroup>
</Project>
14 changes: 14 additions & 0 deletions bdist/dotnet/Directory.Build.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<Project>
<PropertyGroup>
<GenerateNuspecDependsOn>$(GenerateNuspecDependsOn);SetVersionFromGitTag</GenerateNuspecDependsOn>
</PropertyGroup>

<Target Name="SetVersionFromGitTag">
<Exec Command="git describe --tags" ConsoleToMSBuild="true">
<Output TaskParameter="ConsoleOutput" PropertyName="_Version" />
</Exec>
<PropertyGroup>
<PackageVersion>$(_Version.Trim('v').Split('-')[0])</PackageVersion>
</PropertyGroup>
</Target>
</Project>
2 changes: 2 additions & 0 deletions bdist/dotnet/global-tool/ReadMe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Protolint (global tool)

Empty file added bdist/dotnet/global-tool/_._
Empty file.
7 changes: 7 additions & 0 deletions bdist/dotnet/global-tool/posix/DotnetToolSettings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<DotNetCliTool Version="1">
<Commands>
<Command Name="dotnet-protolint" EntryPoint="dotnet-protolint" Runner="native" />
<Command Name="protoc-gen-protolint" EntryPoint="protoc-gen-protolint" Runner="native" />
</Commands>
</DotNetCliTool>
129 changes: 129 additions & 0 deletions bdist/dotnet/global-tool/protolint-global-tool.msbuildproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
<Project Sdk="Microsoft.Build.NoTargets/3.7.56">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<DefaultProjectTypeGuid>{2F08BC15-189B-4804-B644-653F34C968A8}</DefaultProjectTypeGuid>
<GenerateNuspecDependsOn>_WarnToolNotPossibleYet;$(GenerateNuspecDependsOn);_RenameOutputFiles</GenerateNuspecDependsOn>
</PropertyGroup>

<PropertyGroup>
<PackageId>yoheimuta.protolint.globaltool</PackageId>
<PackageVersion></PackageVersion>
<Authors>yoheimuta; carstencodes</Authors>
<Title>Protolint Global Tool</Title>
<Description>A pluggable linter and fixer to enforce Protocol Buffer style and conventions.</Description>
<Copyright>Copyright (c) 2018 yohei yoshimuta</Copyright>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<!--<PackageLicenseFile>$(MsBuildThisFileDirectory)../../../LICENSE</PackageLicenseFile>-->
<PackageProjectUrl>https://github.com/yoheimuta/protolint</PackageProjectUrl>
<PackageReadmeFile>ReadMe.md</PackageReadmeFile>
<PackageTags>protolint;protocol-buffers;protobuf;linter</PackageTags>
<PackageType>DotnetTool</PackageType>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<IsTool>true</IsTool>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="NuGet.Build.Tasks.Pack" Version="6.9.1">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<None
Include="ReadMe.md"
Pack="true"
PackagePath="" />
<None
Include="_._"
Pack="true"
PackagePath="lib/netstandard2.0" />
<None
Include="posix/DotnetToolSettings.xml"
Pack="true"
PackagePath="tools/osx-x64/;tools/osx-arm64/;tools/linux-x64/;tools/linux-arm/;tools/linux-arm64/" />
<None
Include="windows/DotnetToolSettings.xml"
Pack="true"
PackagePath="tools/win-x64/;tools/win-arm64/" />
<None
Include="$(ProtolintGoReleaserDistDir)protolint_darwin_amd64_v1/dotnet-protolint"
Pack="true"
PackagePath="tools/osx-x64/" />
<None
Include="$(ProtolintGoReleaserDistDir)protoc-gen-protolint_darwin_amd64_v1/protoc-gen-protolint"
Pack="true"
PackagePath="tools/osx-x64/" />
<None
Include="$(ProtolintGoReleaserDistDir)protolint_darwin_arm64/dotnet-protolint"
Pack="true"
PackagePath="tools/osx-arm64/" />
<None
Include="$(ProtolintGoReleaserDistDir)protoc-gen-protolint_darwin_arm64/protoc-gen-protolint"
Pack="true"
PackagePath="tools/osx-arm64/" />
<None
Include="$(ProtolintGoReleaserDistDir)protolint_linux_amd64_v1/dotnet-protolint"
Pack="true"
PackagePath="tools/linux-x64/" />
<None
Include="$(ProtolintGoReleaserDistDir)protoc-gen-protolint_linux_amd64_v1/protoc-gen-protolint"
Pack="true"
PackagePath="tools/linux-x64/" />
<None
Include="$(ProtolintGoReleaserDistDir)protolint_linux_arm_7/dotnet-protolint"
Pack="true"
PackagePath="tools/linux-arm/" />
<None
Include="$(ProtolintGoReleaserDistDir)protoc-gen-protolint_linux_arm_7/protoc-gen-protolint"
Pack="true"
PackagePath="tools/linux-arm/" />
<None
Include="$(ProtolintGoReleaserDistDir)protolint_linux_arm64/dotnet-protolint"
Pack="true"
PackagePath="tools/linux-arm64/" />
<None
Include="$(ProtolintGoReleaserDistDir)protoc-gen-protolint_linux_arm64/protoc-gen-protolint"
Pack="true"
PackagePath="tools/linux-arm64/" />
<None
Include="$(ProtolintGoReleaserDistDir)protolint_windows_amd64_v1/dotnet-protolint.exe"
Pack="true"
PackagePath="tools/win-x64/" />
<None
Include="$(ProtolintGoReleaserDistDir)protoc-gen-protolint_windows_amd64_v1/protoc-gen-protolint.exe"
Pack="true"
PackagePath="tools/win-x64/" />
<None
Include="$(ProtolintGoReleaserDistDir)protolint_windows_arm64/dotnet-protolint.exe"
Pack="true"
PackagePath="tools/win-arm64/" />
<None
Include="$(ProtolintGoReleaserDistDir)protoc-gen-protolint_windows_arm64/protoc-gen-protolint.exe"
Pack="true"
PackagePath="tools/win-arm64/" />
</ItemGroup>

<ItemGroup>
<_FilesToRename Include="$(ProtolintGoReleaserDistDir)/protolint*/protolint" />
<_FilesToRename Include="$(ProtolintGoReleaserDistDir)/protolint*/protolint.exe" />
</ItemGroup>

<Target Name="_RenameOutputFiles"
Inputs="@(_FilesToRename)"
Outputs="@(_FilesToRename->'%(Directory)dotnet-%(FileName)%(Extension)')">
<Copy SourceFiles="%(_FilesToRename.Identity)"
DestinationFiles="$(ProtolintGoReleaserDistDir)/%(_FilesToRename.RecursiveDir)dotnet-%(_FilesToRename.FileName)%(_FilesToRename.Extension)"
SkipUnchangedFiles="true" />
</Target>

<Target Name="_WarnToolNotPossibleYet">
<Warning Text="The global tool cannot be build using native packaging yet. Refer to https://github.com/dotnet/sdk/issues/9503 for detail." />
</Target>

</Project>
7 changes: 7 additions & 0 deletions bdist/dotnet/global-tool/windows/DotnetToolSettings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<DotNetCliTool Version="1">
<Commands>
<Command Name="dotnet-protolint" EntryPoint="dotnet-protolint.exe" Runner="native" />
<Command Name="protoc-gen-protolint" EntryPoint="protoc-gen-protolint.exe" Runner="native" />
</Commands>
</DotNetCliTool>
22 changes: 22 additions & 0 deletions bdist/dotnet/protolint.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.31903.59
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2F08BC15-189B-4804-B644-653F34C968A8}") = "protolint-global-tool", "global-tool\protolint-global-tool.msbuildproj", "{9F709A95-B632-4507-83CC-5750BBF2C9CC}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{9F709A95-B632-4507-83CC-5750BBF2C9CC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9F709A95-B632-4507-83CC-5750BBF2C9CC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9F709A95-B632-4507-83CC-5750BBF2C9CC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9F709A95-B632-4507-83CC-5750BBF2C9CC}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal

0 comments on commit 97fb2f6

Please sign in to comment.