Skip to content

Commit d815519

Browse files
committed
make the examples executable with the local project
1 parent b7df91f commit d815519

4 files changed

Lines changed: 58 additions & 0 deletions

File tree

examples/Directory.Build.props

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!--
2+
SPDX-FileCopyrightText: 2025 smdn <smdn@smdn.jp>
3+
SPDX-License-Identifier: MIT
4+
-->
5+
<Project>
6+
<PropertyGroup>
7+
<!--
8+
Set this property to `true` if you want to build and run the examples using the local projects
9+
instead of published NuGet packages.
10+
-->
11+
<UseLocalProjectInsteadOfPublishedPackage>false</UseLocalProjectInsteadOfPublishedPackage>
12+
</PropertyGroup>
13+
</Project>

examples/Directory.Build.targets

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<!--
2+
SPDX-FileCopyrightText: 2025 smdn <smdn@smdn.jp>
3+
SPDX-License-Identifier: MIT
4+
-->
5+
<Project InitialTargets="ReplaceSmdnExtensionsMtpLiquidTestReportsPackageReferencesToProjectReferences">
6+
<!-- Replace PackageReference to ProjectReference of the local project -->
7+
<Target
8+
Name="ReplaceSmdnExtensionsMtpLiquidTestReportsPackageReferencesToProjectReferences"
9+
Condition=" '$(UseLocalProjectInsteadOfPublishedPackage)' == 'true' "
10+
>
11+
<ItemGroup>
12+
<_SmdnExtensionsMtpLiquidTestReportsReference
13+
Include="@(PackageReference)"
14+
Condition="$([System.String]::new('%(Identity)').StartsWith('Smdn.Extensions.Mtp.LiquidTestReports'))"
15+
ProjectPath="$(MSBuildThisFileDirectory)..\src\%(Identity)\%(Identity).csproj"
16+
/>
17+
</ItemGroup>
18+
19+
<ItemGroup>
20+
<!-- Remove package references to Smdn.Extensions.Mtp.LiquidTestReports.* -->
21+
<PackageReference Remove="@(_SmdnExtensionsMtpLiquidTestReportsReference)" />
22+
23+
<!-- Include project reference to Smdn.Extensions.Mtp.LiquidTestReports.* -->
24+
<ProjectReference Include="%(_SmdnExtensionsMtpLiquidTestReportsReference.ProjectPath)"/>
25+
</ItemGroup>
26+
</Target>
27+
</Project>

examples/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,8 @@
22

33
## How to run examples
44
Move to each example directory and execute the command `dotnet test`.
5+
6+
## How to modify libraries
7+
Each example in this directory by default refers to published NuGet packages.
8+
9+
You can change the property `UseLocalProjectInsteadOfPublishedPackage` in file [Directory.Build.props](./Directory.Build.props) to refer to a local project by changing it to `true`.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!--
2+
SPDX-FileCopyrightText: 2025 smdn <smdn@smdn.jp>
3+
SPDX-License-Identifier: MIT
4+
-->
5+
<Project>
6+
<Import Project="$(MSBuildThisFileDirectory)..\Directory.Build.props"/>
7+
8+
<!-- When using an extension built from source, load the props file to enable the extension.-->
9+
<Import
10+
Project="$(MSBuildThisFileDirectory)..\..\src\Smdn.Extensions.Mtp.LiquidTestReports\buildMultiTargeting\Smdn.Extensions.Mtp.LiquidTestReports.props"
11+
Condition="'$(UseLocalProjectInsteadOfPublishedPackage)' == 'true'"
12+
/>
13+
</Project>

0 commit comments

Comments
 (0)