Skip to content

Commit

Permalink
add WmiLight.props and WmiLight.targets for easy static linking
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinKuschnik committed Dec 11, 2023
1 parent f84bc39 commit f56ba75
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 9 deletions.
13 changes: 12 additions & 1 deletion .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,20 +76,31 @@ jobs:
Remove-Item $zip_file
# create folders for native runtime DLLs
New-Item 'nuget-packages\unpacked\runtimes\win-x64\native\' -Type Directory
New-Item 'nuget-packages\unpacked\runtimes\win-x86\native\' -Type Directory
# create folders native libs
New-Item 'nuget-packages\unpacked\lib\native\win-x64\' -Type Directory
New-Item 'nuget-packages\unpacked\lib\native\win-x86\' -Type Directory
# create folders for WmiLight.props and WmiLight.targets
New-Item 'nuget-packages\unpacked\build\' -Type Directory
# copy native runtime DLLs for dynamic linking
Copy-Item 'WmiLight.Native\bin\${{env.BUILD_CONFIGURATION}}\x64\WmiLight.Native.dll' 'nuget-packages\unpacked\runtimes\win-x64\native\'
Copy-Item 'WmiLight.Native\bin\${{env.BUILD_CONFIGURATION}}\x86\WmiLight.Native.dll' 'nuget-packages\unpacked\runtimes\win-x86\native\'
# copy native libs and .pdb files for static linking
Copy-Item 'WmiLight.Native\bin\${{env.BUILD_CONFIGURATION}}\x64\WmiLight.Native.lib' 'nuget-packages\unpacked\lib\native\win-x64\'
Copy-Item 'WmiLight.Native\bin\${{env.BUILD_CONFIGURATION}}\x64\WmiLight.Native.pdb' 'nuget-packages\unpacked\lib\native\win-x64\'
Copy-Item 'WmiLight.Native\bin\${{env.BUILD_CONFIGURATION}}\x86\WmiLight.Native.lib' 'nuget-packages\unpacked\lib\native\win-x86\'
Copy-Item 'WmiLight.Native\bin\${{env.BUILD_CONFIGURATION}}\x86\WmiLight.Native.pdb' 'nuget-packages\unpacked\lib\native\win-x86\'
# copy WmiLight.props and WmiLight.targets
Copy-Item 'WmiLight\.nuget\.build\WmiLight.props' 'nuget-packages\unpacked\build\'
Copy-Item 'WmiLight\.nuget\.build\WmiLight.targets' 'nuget-packages\unpacked\build\'
Compress-Archive 'nuget-packages\unpacked\*' $zip_file
Rename-Item $zip_file ([io.path]::GetFileName($nuget_package_name))
Expand Down
8 changes: 4 additions & 4 deletions WmiLight.Native/WmiLight.Native.rc
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ END
//

VS_VERSION_INFO VERSIONINFO
FILEVERSION 5,1,0,0
PRODUCTVERSION 5,1,0,0
FILEVERSION 5,1,1,0
PRODUCTVERSION 5,1,1,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
Expand All @@ -61,12 +61,12 @@ BEGIN
BEGIN
VALUE "CompanyName", "Martin Kuschnik"
VALUE "FileDescription", "The native part of the WmiLight lib."
VALUE "FileVersion", "5.1.0.0"
VALUE "FileVersion", "5.1.1.0"
VALUE "InternalName", "WmiLight.Native"
VALUE "LegalCopyright", "Copyright 2023 Martin Kuschnik"
VALUE "OriginalFilename", "WmiLight.Native.dll"
VALUE "ProductName", "WmiLight"
VALUE "ProductVersion", "5.1.0.0"
VALUE "ProductVersion", "5.1.1.0"
END
END
BLOCK "VarFileInfo"
Expand Down
6 changes: 6 additions & 0 deletions WmiLight.sln
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WmiLight.Native", "WmiLight
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WmiCompare", "WmiCompare\WmiCompare.csproj", "{3B555BF3-9FAF-4754-AE49-3B5A5CC16054}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{4315B3D9-F82D-41D5-AAEF-9EBD78F844C1}"
ProjectSection(SolutionItems) = preProject
.github\workflows\dotnet.yml = .github\workflows\dotnet.yml
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -100,6 +105,7 @@ Global
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{582EB9E1-0602-4CA6-8BF1-3FA269370402} = {1E5BFE7B-DA04-4FED-8025-873524C76B83}
{4315B3D9-F82D-41D5-AAEF-9EBD78F844C1} = {00FA0660-8B93-4087-A693-BDB73D5A601C}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {3EF104CD-B33D-41E5-804A-52DD9906C0B9}
Expand Down
8 changes: 8 additions & 0 deletions WmiLight/.nuget/.build/WmiLight.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Condition="$(PublishWmiLightStaticallyLinked) == true">
<!-- https://learn.microsoft.com/en-us/dotnet/core/deploying/native-aot/interop -->
<DirectPInvoke Include="WmiLight.Native" />
<NativeLibrary Include="wbemuuid.lib" Condition="$(RuntimeIdentifier.StartsWith('win'))" />
<NativeLibrary Include="$(MSBuildThisFileDirectory)..\lib\native\$(RuntimeIdentifier)\WmiLight.Native.lib" Condition="$(RuntimeIdentifier.StartsWith('win'))" />
</ItemGroup>
</Project>
8 changes: 8 additions & 0 deletions WmiLight/.nuget/.build/WmiLight.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- The DLL file will be copied when it is published, so we need to remove it -->
<Target Name="RemoveFileToPublish" AfterTargets="ComputeResolvedFilesToPublishList" Condition="$(PublishWmiLightStaticallyLinked) == true">
<ItemGroup>
<ResolvedFileToPublish Remove="@(ResolvedFileToPublish)" Condition="'%(ResolvedFileToPublish.RelativePath)' == 'WmiLight.Native.dll'" />
</ItemGroup>
</Target>
</Project>
9 changes: 5 additions & 4 deletions WmiLight/WmiLight.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@
<SignAssembly>True</SignAssembly>
<AssemblyOriginatorKeyFile>private_key.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
<ItemGroup>
<Folder Include="Properties\NugetPackageContent\" />
</ItemGroup>
<PropertyGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net7.0')) Or $([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net8.0'))">
<IsTrimmable>true</IsTrimmable>
</PropertyGroup>
Expand All @@ -26,7 +23,7 @@
</Target>
<PropertyGroup />
<PropertyGroup>
<Version>5.1.0</Version>
<Version>5.1.1-pre</Version>
<PackageId>WmiLight</PackageId>
<Authors>Martin Kuschnik</Authors>
<Company>Martin Kuschnik</Company>
Expand All @@ -42,6 +39,10 @@
<DelaySign>False</DelaySign>
<Title></Title>
</PropertyGroup>
<ItemGroup>
<None Include=".nuget\.build\WmiLight.props" />
<None Include=".nuget\.build\WmiLight.targets" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.DotNet.UpgradeAssistant.Extensions.Default.Analyzers" Version="0.3.261302">
<PrivateAssets>all</PrivateAssets>
Expand Down

0 comments on commit f56ba75

Please sign in to comment.