Skip to content

Commit e0ebf83

Browse files
committed
Use 'UnmanagedExports.Repack.Upgrade`
Eliminates a lingering build dependency on an ancient version of Microsoft.Build.Utilities (v2.0.0.0), which won't be available in environments where .NET Framework 3.5 build tools have not been installed [^1] See https://www.nuget.org/packages/UnmanagedExports.Repack.Upgrade Caveats ........ * initial builds must now run a 'Restore' task first [^2] * this adds package references with the 'GeneratePathProperty' attribute, so at least VS 2019 (i.e. MSBuild 16), or NuGet 5.0, is required [^3] [^1] https://community.notepad-plus-plus.org/post/93058 [^2] https://learn.microsoft.com/nuget/reference/msbuild-targets#restore-target [^3] https://learn.microsoft.com/nuget/consume-packages/package-references-in-project-files#generatepathproperty
1 parent 470b8f8 commit e0ebf83

File tree

8 files changed

+22
-50
lines changed

8 files changed

+22
-50
lines changed

.github/workflows/CI_build.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ jobs:
2828
uses: microsoft/setup-msbuild@v2.0.0
2929

3030
- name: MSBuild of solution
31-
run: msbuild NppCSharpPluginPack/NppCSharpPluginPack.sln /p:configuration="${{ matrix.build_configuration }}" /p:platform="${{ matrix.build_platform }}" /m /verbosity:minimal
31+
run: >
32+
msbuild /t:Restore NppCSharpPluginPack/NppCSharpPluginPack.sln
33+
msbuild NppCSharpPluginPack/NppCSharpPluginPack.sln /p:configuration="${{ matrix.build_configuration }}" /p:platform="${{ matrix.build_platform }}" /m /verbosity:minimal
3234
3335
- name: Archive artifacts for x64
3436
if: matrix.build_platform == 'x64' && matrix.build_configuration == 'Release'

NppCSharpPluginPack/NppCSharpPluginPack.csproj

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,14 @@
6565
<StartProgram Condition="'$(Platform)'=='x64'">$(ProgramW6432)\Notepad++\notepad++.exe</StartProgram>
6666
<StartProgram Condition="'$(Platform)'=='x86'">$(MSBuildProgramFiles32)\Notepad++\notepad++.exe</StartProgram>
6767
</PropertyGroup>
68+
<PropertyGroup>
69+
<RestorePackagesPath>$(MSBuildProjectDirectory)\packages</RestorePackagesPath>
70+
</PropertyGroup>
71+
<ItemGroup>
72+
<PackageReference Include="UnmanagedExports.Repack.Upgrade" Version="1.2.1" GeneratePathProperty="true">
73+
<ExcludeAssets>all</ExcludeAssets>
74+
</PackageReference>
75+
</ItemGroup>
6876
<ItemGroup>
6977
<!-- forms -->
7078
<Compile Include="Forms\NppFormHelper.cs" />
@@ -181,7 +189,8 @@
181189
</ItemGroup>
182190
<ItemGroup />
183191
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
184-
<Import Project="$(MSBuildProjectDirectory)\PluginInfrastructure\DllExport\NppPlugin.DllExport.targets" />
192+
<Import Condition="Exists($(PkgUnmanagedExports_Repack_Upgrade))"
193+
Project="$(PkgUnmanagedExports_Repack_Upgrade)\build\UnmanagedExports.Repack.Upgrade.targets" />
185194
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
186195
Other similar extension points exist, see Microsoft.Common.targets.
187196
<Target Name="BeforeBuild">

NppCSharpPluginPack/PluginInfrastructure/DllExport/DllExportAttribute.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,15 @@
22
using System;
33
using System.Runtime.InteropServices;
44

5-
namespace NppPlugin.DllExport
5+
namespace RGiesecke.DllExport
66
{
7+
/// <summary>
8+
/// The fully qualified type name must be <c>RGiesecke.DllExport.DllExportAttribute</c> in order to work with the pre-configured task in <c>UnmanagedExports.Repack.Upgrade.targets</c>.
9+
/// This implementation could be avoided if we referenced the <c>RGiesecke.DllExport.Metadata</c> assembly, but then it will look like a runtime dependency, and be copied to the build output directory.
10+
/// <para>
11+
/// See <seealso href="https://github.com/stevenengland/UnmanagedExports.Repack.Upgrade/blob/master/nuget/build/UnmanagedExports.Repack.Upgrade.targets"/>
12+
/// </para>
13+
/// </summary>
714
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
815
partial class DllExportAttribute : Attribute
916
{
Binary file not shown.
Binary file not shown.
Binary file not shown.

NppCSharpPluginPack/PluginInfrastructure/DllExport/NppPlugin.DllExport.targets

Lines changed: 0 additions & 46 deletions
This file was deleted.

NppCSharpPluginPack/PluginInfrastructure/UnmanagedExports.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
using System;
33
using System.Runtime.InteropServices;
44
using Kbg.NppPluginNET.PluginInfrastructure;
5-
using NppPlugin.DllExport;
5+
using RGiesecke.DllExport;
66

77
namespace Kbg.NppPluginNET
88
{

0 commit comments

Comments
 (0)