Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
ied206 committed Feb 14, 2022
2 parents 131fa03 + 6d7416d commit b508276
Show file tree
Hide file tree
Showing 13 changed files with 93 additions and 67 deletions.
2 changes: 1 addition & 1 deletion ManagedWimLib.Tests/GetInfoTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public void ResolveImage()
ResolveImageTemplate("MultiImage.wim", "*", Wim.AllImages);
}

public void ResolveImageTemplate(string fileName, string imageNameOrNum, int expected)
public static void ResolveImageTemplate(string fileName, string imageNameOrNum, int expected)
{
string wimFile = Path.Combine(TestSetup.SampleDir, fileName);
using (Wim wim = Wim.OpenWim(wimFile, OpenFlags.None))
Expand Down
8 changes: 4 additions & 4 deletions ManagedWimLib.Tests/ManagedWimLib.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="coverlet.collector" Version="3.0.3">
<PackageReference Include="coverlet.collector" Version="3.1.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" />
<PackageReference Include="MSTest.TestAdapter" Version="2.2.3" />
<PackageReference Include="MSTest.TestFramework" Version="2.2.3" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
<PackageReference Include="MSTest.TestAdapter" Version="2.2.8" />
<PackageReference Include="MSTest.TestFramework" Version="2.2.8" />
</ItemGroup>

<ItemGroup>
Expand Down
9 changes: 5 additions & 4 deletions ManagedWimLib.Tests/TestSetup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,11 @@ public static void Cleanup()
#region GetNativeLibPath
private static string GetNativeLibPath()
{
string libBaseDir = TestHelper.GetProgramAbsolutePath();
string libDir = string.Empty;

#if !NETFRAMEWORK
libDir = "runtimes";
libDir = Path.Combine(libDir, "runtimes");
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
libDir = Path.Combine(libDir, "win-");
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
Expand Down Expand Up @@ -104,11 +105,11 @@ private static string GetNativeLibPath()

string libPath = null;
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
libPath = Path.Combine(libDir, "libwim-15.dll");
libPath = Path.Combine(libBaseDir, libDir, "libwim-15.dll");
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
libPath = Path.Combine(libDir, "libwim.so");
libPath = Path.Combine(libBaseDir, libDir, "libwim.so");
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
libPath = Path.Combine(libDir, "libwim.dylib");
libPath = Path.Combine(libBaseDir, libDir, "libwim.dylib");

if (libPath == null)
throw new PlatformNotSupportedException($"Unable to find native library.");
Expand Down
11 changes: 8 additions & 3 deletions ManagedWimLib.sln
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27703.2018
# Visual Studio Version 17
VisualStudioVersion = 17.0.32126.317
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ManagedWimLib", "ManagedWimLib\ManagedWimLib.csproj", "{73BDCA22-081D-489E-95E7-A02A6778BB7C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ManagedWimLib.Tests", "ManagedWimLib.Tests\ManagedWimLib.Tests.csproj", "{83E13236-FE14-47BA-BA3C-9028597FAEDC}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ManagedWimLib.Tests", "ManagedWimLib.Tests\ManagedWimLib.Tests.csproj", "{83E13236-FE14-47BA-BA3C-9028597FAEDC}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{14D989FD-A32C-444F-8729-B96D46E33691}"
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
24 changes: 17 additions & 7 deletions ManagedWimLib/ManagedWimLib.csproj
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net451;netstandard2.0;netstandard2.1</TargetFrameworks>
<TargetFrameworks Condition="'$(OS)' != 'Windows_NT'">netstandard2.0;netstandard2.1</TargetFrameworks>
<TargetFrameworks>net451;netstandard2.0;netcoreapp3.1</TargetFrameworks>
<TargetFrameworks Condition="'$(OS)' != 'Windows_NT'">netstandard2.0;netcoreapp3.1</TargetFrameworks>
<PackageId>ManagedWimLib</PackageId>
<Title>ManagedWimLib</Title>
<LangVersion>latest</LangVersion>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Version>2.3.0</Version>
<Version>2.4.0</Version>
<Authors>Eric Biggers, Hajin Jang</Authors>
<Company>Joveler</Company>
<Description>Native wimlib wrapper library for .NET.
Expand All @@ -17,12 +17,13 @@ Supports Windows, Linux and macOS.</Description>
<PackageProjectUrl>https://github.com/ied206/ManagedWimLib</PackageProjectUrl>
<PackageIcon>images\Logo.png</PackageIcon>
<RepositoryUrl>https://github.com/ied206/ManagedWimLib</RepositoryUrl>
<PackageReleaseNotes>- Update included wimlib to 1.13.5.</PackageReleaseNotes>
<PackageReleaseNotes>- Official support for ARM64 macOS.
- Replace .NET Standard 2.1 target with .NET Core 3.1.</PackageReleaseNotes>
<PackageTags>wim wimlib dism imagex archive native pinvoke interop</PackageTags>
</PropertyGroup>
<!-- PackageReference -->
<ItemGroup>
<PackageReference Include="Joveler.DynLoader" Version="2.1.0" />
<PackageReference Include="Joveler.DynLoader" Version="2.1.1" />
<PackageReference Include="System.Memory" Version="4.5.4" Condition=" '$(TargetFramework)' == 'net451' or '$(TargetFramework)' == 'netstandard2.0' " />
</ItemGroup>
<!-- Native Library for .NET Framework 4.5.1 -->
Expand All @@ -36,8 +37,8 @@ Supports Windows, Linux and macOS.</Description>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<!-- Native Library for .NET Standard 2.0 & 2.1 -->
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0' or '$(TargetFramework)' == 'netstandard2.1'">
<!-- Native Library for .NET Standard 2.0 & .NET Core 3.1 -->
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0' or '$(TargetFramework)' == 'netcoreapp3.1'">
<None Include="runtimes\win-x86\native\*.dll">
<Link>runtimes\win-x86\native\%(FileName)%(Extension)</Link> <!-- Project Reference -->
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
Expand Down Expand Up @@ -66,6 +67,10 @@ Supports Windows, Linux and macOS.</Description>
<Link>runtimes\osx-x64\native\%(FileName)%(Extension)</Link> <!-- Project Reference -->
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="runtimes\osx-arm64\native\*.dylib">
<Link>runtimes\osx-arm64\native\%(FileName)%(Extension)</Link> <!-- Project Reference -->
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<!-- NuGet Pacakge -->
<ItemGroup>
Expand All @@ -81,5 +86,10 @@ Supports Windows, Linux and macOS.</Description>
<None Include="runtimes\linux-arm\native\*.so" Pack="true" PackagePath="runtimes\linux-arm\native" />
<None Include="runtimes\linux-arm64\native\*.so" Pack="true" PackagePath="runtimes\linux-arm64\native" />
<None Include="runtimes\osx-x64\native\*.dylib" Pack="true" PackagePath="runtimes\osx-x64\native" />
<None Include="runtimes\osx-arm64\native\*.dylib" Pack="true" PackagePath="runtimes\osx-arm64\native" />
</ItemGroup>
<!-- etc -->
<ItemGroup>
<None Include="..\.editorconfig" Link=".editorconfig" />
</ItemGroup>
</Project>
2 changes: 0 additions & 2 deletions ManagedWimLib/NativeStructs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1282,8 +1282,6 @@ public enum CompressorFlags : uint
#region Native wimlib structures
#region WimInfo
[StructLayout(LayoutKind.Sequential)]
[SuppressMessage("ReSharper", "FieldCanBeMadeReadOnly.Local")]
[SuppressMessage("ReSharper", "PrivateFieldCanBeConvertedToLocalVariable")]
public class WimInfo
{
/// <summary>
Expand Down
17 changes: 1 addition & 16 deletions ManagedWimLib/WimLibLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,11 @@ You should have received a copy of the GNU Lesser General Public License

using Joveler.DynLoader;
using System;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
// ReSharper disable FieldCanBeMadeReadOnly.Global
// ReSharper disable MemberCanBePrivate.Global
// ReSharper disable UnusedMember.Global
// ReSharper disable StringLiteralTypo
// ReSharper disable ClassNeverInstantiated.Global
// ReSharper disable InconsistentNaming
// ReSharper disable EnumUnderlyingTypeIsInt
// ReSharper disable FieldCanBeMadeReadOnly.Local
// ReSharper disable PrivateFieldCanBeConvertedToLocalVariable
#pragma warning disable 169
#pragma warning disable 414
#pragma warning disable 649

#pragma warning disable IDE0044
#pragma warning disable IDE0063 // 간단한 'using' 문 사용

namespace ManagedWimLib
{
Expand Down Expand Up @@ -556,7 +543,6 @@ protected override void ResetFunctions()

#region WimLib Function Pointers
#region UTF-16 Instances
[SuppressMessage("ReSharper", "MemberHidesStaticFromOuterClass")]
internal class Utf16d
{
internal const UnmanagedType StrType = UnmanagedType.LPWStr;
Expand Down Expand Up @@ -923,7 +909,6 @@ public CaptureSourceBaseL64(string fsSourcePath, string wimTargetPath)
#endregion

#region UTF-8 Instances
[SuppressMessage("ReSharper", "MemberHidesStaticFromOuterClass")]
internal class Utf8d
{
internal const UnmanagedType StrType = UnmanagedType.LPStr;
Expand Down
2 changes: 0 additions & 2 deletions ManagedWimLib/WimStruct.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,9 @@ You should have received a copy of the GNU Lesser General Public License
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
// ReSharper disable UnusedMember.Global

namespace ManagedWimLib
{
[SuppressMessage("ReSharper", "RedundantExplicitArraySize")]
public class Wim : IDisposable
{ // Wrapper of WIMStruct and wimlib API
#region (static) LoadManager
Expand Down
Binary file not shown.
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ ManagedWimLib can be installed via [nuget](https://www.nuget.org/packages/Manage

### Targeted .NET platforms

- .NET Standard 2.1 (.NET Core 3.0+)
- .NET Standard 2.0 (.NET Framework 4.6.1+, .NET Core 2.0+)
- .NET Core 3.1
- .NET Standard 2.0
- .NET Framework 4.5.1

If you need .NET Standard 1.3 support, use [1.2.x version](https://www.nuget.org/packages/ManagedWimLib/1.2.4) instead.<br>
Expand All @@ -43,8 +43,7 @@ If you need .NET Framework 4.5 support, use [1.1.x version](https://www.nuget.or
| | arm | Yes |
| | arm64 | Yes |
| macOS | x64 | Yes |

macOS arm64 should be supported on theory, but I do not have access to an Apple Sillicon device to test. Please contribute if you have an ARM64 macOS machine.
| | arm64 | Yes |

#### Tested linux distributions

Expand Down
50 changes: 27 additions & 23 deletions USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,12 @@ public static void InitNativeLibrary()
}
```

#### For .NET Standard 2.0+:
#### For .NET Standard 2.0+, NET Core 3.1+:

```cs
public static void InitNativeLibrary()
{
string libBaseDir = AppDomain.CurrentDomain.BaseDirectory;
string libDir = "runtimes";
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
libDir = Path.Combine(libDir, "win-");
Expand All @@ -66,13 +67,14 @@ public static void InitNativeLibrary()
}
libDir = Path.Combine(libDir, "native");

// macOS ARM64 requires native library path to be absolute path.
string libPath = null;
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
libPath = Path.Combine(libDir, "libwim-15.dll");
libPath = Path.Combine(libBaseDir, libDir, "libwim-15.dll");
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
libPath = Path.Combine(libDir, "libwim.so");
libPath = Path.Combine(libBaseDir, libDir, "libwim.so");
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
libPath = Path.Combine(libDir, "libwim.dylib");
libPath = Path.Combine(libBaseDir, libDir, "libwim.dylib");

if (libPath == null)
throw new PlatformNotSupportedException($"Unable to find native library.");
Expand Down Expand Up @@ -100,17 +102,18 @@ ManagedWimLib comes with sets of binaries of `wimlib 1.13.4`. They will be copie

- Create an empty file named `ManagedWimLib.Precompiled.Exclude` in the project directory to prevent a copy of the package-embedded binary.

#### For .NET Standard 2.0+
#### For .NET Standard 2.0, NET Core 3.1+

| Platform | Binary | License |
|-------------------|-----------------------------------------------------|----------------------|
| Windows x86 | `$(OutDir)\runtimes\win-x86\native\libwim-15.dll` | LGPLv3 |
| Windows x64 | `$(OutDir)\runtimes\win-x64\native\libwim-15.dll` | LGPLv3 |
| Windows arm64 | `$(OutDir)\runtimes\win-arm64\native\libwim-15.dll` | LGPLv3 |
| Ubuntu 20.04 x64 | `$(OutDir)\runtimes\linux-x64\native\libwim.so` | LGPLv3 (w/o NTFS-3G) |
| Debian 11 armhf | `$(OutDir)\runtimes\linux-arm\native\libwim.so` | LGPLv3 (w/o NTFS-3G) |
| Debian 11 arm64 | `$(OutDir)\runtimes\linux-arm64\native\libwim.so` | LGPLv3 (w/o NTFS-3G) |
| macOS Big Sur x64 | `$(OutDir)\runtimes\osx-x64\native\libwim.dylib` | LGPLv3 (w/o NTFS-3G) |
| Platform | Binary | License |
|----------------------|-----------------------------------------------------|----------------------|
| Windows x86 | `$(OutDir)\runtimes\win-x86\native\libwim-15.dll` | LGPLv3 |
| Windows x64 | `$(OutDir)\runtimes\win-x64\native\libwim-15.dll` | LGPLv3 |
| Windows arm64 | `$(OutDir)\runtimes\win-arm64\native\libwim-15.dll` | LGPLv3 |
| Ubuntu 20.04 x64 | `$(OutDir)\runtimes\linux-x64\native\libwim.so` | LGPLv3 (w/o NTFS-3G) |
| Debian 11 armhf | `$(OutDir)\runtimes\linux-arm\native\libwim.so` | LGPLv3 (w/o NTFS-3G) |
| Debian 11 arm64 | `$(OutDir)\runtimes\linux-arm64\native\libwim.so` | LGPLv3 (w/o NTFS-3G) |
| macOS Big Sur x64 | `$(OutDir)\runtimes\osx-x64\native\libwim.dylib` | LGPLv3 (w/o NTFS-3G) |
| macOS Monterey arm64 | `$(OutDir)\runtimes\osx-arm64\native\libwim.dylib` | LGPLv3 (w/o NTFS-3G) |

- Linux binaries are not portable. Included binaires may not work on your distribution.
- On Linux, wimlib depends on system-installed `libfuse`.
Expand All @@ -120,15 +123,16 @@ ManagedWimLib comes with sets of binaries of `wimlib 1.13.4`. They will be copie

#### Build Command

| Platform | Binary Source | Dependency |
|-------------------|---------------------------------------------------------------------------------------|-----------------|
| Windows x86 | [Official Release](https://wimlib.net/downloads/wimlib-1.13.3-windows-i686-bin.zip) | - |
| Windows x64 | [Official Release](https://wimlib.net/downloads/wimlib-1.13.3-windows-x86_64-bin.zip) | - |
| Windows arm64 | Compile with MSYS2 and llvm-mingw | - |
| Ubuntu 20.04 x64 | Compile with libxml2 dependency | libfuse |
| Debian 11 armhf | Compile with libxml2 dependency | libfuse |
| Debian 11 arm64 | Compile with libxml2 dependency | libfuse |
| macOS Big Sur x64 | Compile with libxml2 dependency | - |
| Platform | Binary Source | Dependency |
|----------------------|---------------------------------------------------------------------------------------|-----------------|
| Windows x86 | [Official Release](https://wimlib.net/downloads/wimlib-1.13.5-windows-i686-bin.zip) | - |
| Windows x64 | [Official Release](https://wimlib.net/downloads/wimlib-1.13.5-windows-x86_64-bin.zip) | - |
| Windows arm64 | Compile with MSYS2 and llvm-mingw | - |
| Ubuntu 20.04 x64 | Compile with libxml2 dependency | libfuse |
| Debian 11 armhf | Compile with libxml2 dependency | libfuse |
| Debian 11 arm64 | Compile with libxml2 dependency | libfuse |
| macOS Big Sur x64 | Compile with libxml2 dependency | - |
| macOS Monterey arm64 | Compile with libxml2 dependency | - |

### Custom binary

Expand Down
16 changes: 15 additions & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,18 @@ steps:
inputs:
command: 'test'
projects: '**/*.Tests/*.csproj'
arguments: '--configuration $(buildConfiguration) --logger="console;verbosity=detailed"'
arguments: '--configuration $(buildConfiguration) --logger="console;verbosity=detailed" --collect:"XPlat Code Coverage" --settings:"$(Build.SourcesDirectory)/coverlet.runsettings"'
# https://stackoverflow.com/questions/64592534/publish-a-pipeline-azure-devops-code-coverage-report
- task: DotNetCoreCLI@2
displayName: 'Install ReportGenerator Tool'
inputs:
command: 'custom'
custom: 'tool'
arguments: 'install --global dotnet-reportgenerator-globaltool'
- script: 'reportgenerator -reports:$(Agent.TempDirectory)/**/coverage.cobertura.xml -targetdir:"$(Build.ArtifactStagingDirectory)/coverlet" -reporttypes:"Cobertura" -verbosity:"Verbose"'
displayName: 'Merge Code Coverage Reports'
- task: PublishCodeCoverageResults@1
displayName: 'Publish Code Coverage Report'
inputs:
codeCoverageTool: 'Cobertura'
summaryFileLocation: '$(Build.ArtifactStagingDirectory)/coverlet/Cobertura.xml'
12 changes: 12 additions & 0 deletions coverlet.runsettings
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8" ?>
<RunSettings>
<DataCollectionRunSettings>
<DataCollectors>
<DataCollector friendlyName="XPlat Code Coverage">
<Configuration>
<Format>cobertura</Format>
</Configuration>
</DataCollector>
</DataCollectors>
</DataCollectionRunSettings>
</RunSettings>

0 comments on commit b508276

Please sign in to comment.