Skip to content

Commit

Permalink
asyncapi#197 try by installing local tool
Browse files Browse the repository at this point in the history
  • Loading branch information
SennG committed Jul 7, 2024
1 parent fbbf601 commit 6cc92e3
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 23 deletions.
2 changes: 1 addition & 1 deletion examples/StreetlightsAPI/StreetlightsAPI.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<IsPackable>false</IsPackable>

<!-- Example settings for "AsyncAPI.Saunter.Generator.Build", they are all option though -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,13 @@
<RepositoryUrl>https:/asyncapi/saunter</RepositoryUrl>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<IncludeBuildOutput>true</IncludeBuildOutput>
<IncludeBuildOutput>false</IncludeBuildOutput>
<IncludeSymbols>false</IncludeSymbols>
<PackageProjectUrl>https:/asyncapi/saunter</PackageProjectUrl>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<DevelopmentDependency>true</DevelopmentDependency>
<Version>1.0.0</Version>
<OutputPath>bin/</OutputPath>
</PropertyGroup>

<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
Expand All @@ -32,18 +31,6 @@
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\AsyncAPI.Saunter.Generator.Cli\AsyncAPI.Saunter.Generator.Cli.csproj" />
<ProjectReference Include="..\Saunter\Saunter.csproj" />
<ProjectReference Update="@(ProjectReference)" PrivateAssets="All" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' != 'netstandard2.0' ">
<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="AsyncAPI.NET.Readers" Version="5.2.1" />

<!-- Development Dependencies -->
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
<PackageReference Update="@(PackageReference)" PrivateAssets="All" />
Expand All @@ -53,8 +40,6 @@
<None Include="readme.md" Pack="true" PackagePath="/" />
<None Include="../../assets/logo.png" Pack="true" PackagePath="/" />
<None Include="build/*" Pack="true" PackagePath="/build" />
<None Include="$(OutputPath)net6.0/*" Pack="true" PackagePath="/tools/net6.0/" />
<None Include="$(OutputPath)net8.0/*" Pack="true" PackagePath="/tools/net8.0/" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<PropertyGroup>
<AsyncAPIBuildToolBuildDir>$([System.IO.Path]::GetDirectoryName($(MSBuildThisFileDirectory)))</AsyncAPIBuildToolBuildDir>
<AsyncAPIBuildToolRoot>$([System.IO.Path]::GetDirectoryName($(AsyncAPIBuildToolBuildDir)))</AsyncAPIBuildToolRoot>
<LocalToolConfigFile>./.config/dotnet-tools.json</LocalToolConfigFile>
</PropertyGroup>

<Message Text="AsyncAPI.Build; AsyncAPIDocumentFormats: $(AsyncAPIDocumentFormats)" />
Expand All @@ -18,12 +19,12 @@
<Message Text="AsyncAPI.Build; MSBuildThisFileDirectory: $(MSBuildThisFileDirectory)" />
<Message Text="AsyncAPI.Build; MSBuildProjectFullPath: $(MSBuildProjectFullPath)" />
<Message Text="AsyncAPI.Build; MSBuildProjectDirectory: $(MSBuildProjectDirectory)" />
<Message Text="AsyncAPI.Build; LocalToolConfigFile: $(LocalToolConfigFile)" />

<Exec Command="dotnet new tool-manifest" Condition=" '$([System.IO.File]::Exists($(LocalToolConfigFile)))' == 'false' " />
<Exec Command="dotnet tool install --local AsyncAPI.Saunter.Generator.Cli" />

<Exec Command="dir ." />
<Exec Command="dir $(AsyncAPIBuildToolRoot)" />
<Exec Command="dir $(AsyncAPIBuildToolRoot)/tools" />

<Exec Command="dotnet &quot;$(AsyncAPIBuildToolRoot)/tools/net6.0/AsyncAPI.Saunter.Generator.Cli.dll&quot; tofile --output &quot;$(MSBuildProjectDirectory)/$(AsyncAPIDocumentOutputPath)&quot; --format &quot;$(AsyncAPIDocumentFormats)&quot; --doc &quot;$(AsyncAPIDocumentNames)&quot; --filename &quot;$(AsyncAPIDocumentFilename)&quot; --env &quot;$(AsyncAPIDocumentEnvVars)&quot; &quot;$(MSBuildProjectDirectory)/$(OutputPath)/$(AssemblyTitle).dll&quot;"/>
<Exec Command="dotnet tool run dotnet-asyncapi tofile --output &quot;$(MSBuildProjectDirectory)/$(AsyncAPIDocumentOutputPath)&quot; --format &quot;$(AsyncAPIDocumentFormats)&quot; --doc &quot;$(AsyncAPIDocumentNames)&quot; --filename &quot;$(AsyncAPIDocumentFilename)&quot; --env &quot;$(AsyncAPIDocumentEnvVars)&quot; &quot;$(MSBuildProjectDirectory)/$(OutputPath)/$(AssemblyTitle).dll&quot;"/>
</Target>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public void BuildingCsprojGeneratesSpecFilesTest()
Directory.GetFiles(specDir).Length.ShouldBe(0, $"#Spec files after deleting them all, path: {specDir}");

// Run build
var stdOut = this.Run("dotnet", "build", csprojDir);
var stdOut = this.Run("dotnet", "build", csprojDir).Replace('/', Path.DirectorySeparatorChar).Replace('\\', Path.DirectorySeparatorChar);
stdOut.ShouldContain($"AsyncAPI json successfully written to {Path.Combine(specDir, "streetlights.json")}");
stdOut.ShouldContain($"AsyncAPI yml successfully written to {Path.Combine(specDir, "streetlights.yml")}");
stdOut.ShouldContain("Build succeeded.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public void Pack_Install_Run_Uninstall_Test()
stdOut.ShouldContain("Successfully created package");

stdOut = this.Run("dotnet", "tool install --global --add-source ./bin/Release AsyncAPI.Saunter.Generator.Cli", "../../../../../src/AsyncAPI.Saunter.Generator.Cli");
stdOut = stdOut.Replace("Skipping NuGet package signature verification.", "").Trim();
stdOut.ShouldBeOneOf("You can invoke the tool using the following command: dotnet-asyncapi\r\nTool 'asyncapi.saunter.generator.cli' (version '1.0.1') was successfully installed.",
"Tool 'asyncapi.saunter.generator.cli' was reinstalled with the stable version (version '1.0.1').");

Expand Down

0 comments on commit 6cc92e3

Please sign in to comment.