Skip to content

Commit 53044ff

Browse files
authored
Merge pull request #5 from dorssel/versioning
fix continuous delivery
2 parents 77c3c6a + f6cd1fb commit 53044ff

13 files changed

+59
-49
lines changed

Installer/Installer.wixproj

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,27 +26,19 @@
2626
<OutputName>usbipd-win</OutputName>
2727
<DefineSolutionProperties>false</DefineSolutionProperties>
2828
<PublishDir>..\UsbIpServer\bin\publish</PublishDir>
29-
<!--
30-
This ensures that each x.y.z version has a different product, so every upgrade is a MajorUpgrade.
31-
It also ensures that 2 builds of the same x.y.z version will never be installed simultaneously.
32-
The alternative (WiX AllowSameVersionUpgrades) causes ICE61.
33-
34-
The chance of a hash-collision is much smaller than the chance of forgetting to update ProductId manually.
35-
-->
36-
<ProductId>EA1D5623-E6A7-4E4A-9259-E397$(GitVersion_MajorMinorPatch.GetHashCode().ToString(X8))</ProductId>
3729
</PropertyGroup>
3830
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
3931
<OutputPath>bin\$(Configuration)\</OutputPath>
4032
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
41-
<DefineConstants>Debug;PublishDir=$(PublishDir);DriversDir=$(ProjectDir)..\Drivers;ProductId=$(ProductId)</DefineConstants>
33+
<DefineConstants>Debug;PublishDir=$(PublishDir);DriversDir=$(ProjectDir)..\Drivers</DefineConstants>
4234
<Cultures>en-US</Cultures>
4335
<SuppressAllWarnings>False</SuppressAllWarnings>
4436
<Pedantic>True</Pedantic>
4537
</PropertyGroup>
4638
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">
4739
<OutputPath>bin\$(Configuration)\</OutputPath>
4840
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
49-
<DefineConstants>PublishDir=$(PublishDir);DriversDir=$(ProjectDir)..\Drivers;ProductId=$(ProductId)</DefineConstants>
41+
<DefineConstants>PublishDir=$(PublishDir);DriversDir=$(ProjectDir)..\Drivers</DefineConstants>
5042
<Cultures>en-US</Cultures>
5143
<SuppressAllWarnings>False</SuppressAllWarnings>
5244
<Pedantic>True</Pedantic>
@@ -102,7 +94,7 @@
10294
<Target Name="EnsureWixToolsetInstalled" AfterTargets="BeforeBuild" />
10395
<Target Name="SetTarget" AfterTargets="GetVersion">
10496
<Message Importance="high" Text="Version detected as $(GitVersion_FullSemVer)" />
105-
<CreateProperty Value="$(OutputName)_$(GitVersion_FullSemVer)">
97+
<CreateProperty Value="$(OutputName)_$(GitVersion_MajorMinorPatch)">
10698
<Output TaskParameter="Value" PropertyName="TargetName" />
10799
</CreateProperty>
108100
<CreateProperty Value="$(TargetName)$(TargetExt)">
@@ -114,6 +106,16 @@
114106
<CreateProperty Value="$(TargetName)$(TargetPdbExt)">
115107
<Output TaskParameter="Value" PropertyName="TargetPdbName" />
116108
</CreateProperty>
109+
<!--
110+
This ensures that each x.y.z version has a different ProductId, so every update is a MajorUpgrade.
111+
It also ensures that 2 builds of the same x.y.z version will never be installed simultaneously.
112+
The alternative (WiX AllowSameVersionUpgrades) causes ICE61.
113+
114+
The chance of a hash-collision is much smaller than the chance of forgetting to update ProductId manually.
115+
-->
116+
<CreateProperty Value="$(DefineConstants);ProductId=EA1D5623-E6A7-4E4A-9259-E397$(GitVersion_MajorMinorPatch.GetHashCode().ToString(X8))">
117+
<Output TaskParameter="Value" PropertyName="DefineConstants" />
118+
</CreateProperty>
117119
</Target>
118120
<PropertyGroup>
119121
<PreBuildEvent>del /s /q "$(ProjectDir)..\UsbIpServer\bin\publish" &gt; NUL:

UsbIpServer/AttachedClient.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ You should have received a copy of the GNU General Public License
1616
along with this program. If not, see <https://www.gnu.org/licenses/>.
1717
*/
1818

19-
using Microsoft.Extensions.Logging;
2019
using System;
2120
using System.Buffers.Binary;
2221
using System.Diagnostics.CodeAnalysis;
@@ -25,6 +24,7 @@ You should have received a copy of the GNU General Public License
2524
using System.Runtime.InteropServices;
2625
using System.Threading;
2726
using System.Threading.Tasks;
27+
using Microsoft.Extensions.Logging;
2828
using static UsbIpServer.Interop.Usb;
2929
using static UsbIpServer.Interop.UsbIp;
3030
using static UsbIpServer.Interop.VBoxUsb;
@@ -82,10 +82,10 @@ async Task HandleSubmitAsync(UsbIpHeaderBasic basic, UsbIpHeaderCmdSubmit submit
8282
urb.type = UsbSupTransferType.USBSUP_TRANSFER_TYPE_BULK;
8383
break;
8484
case UsbEndpointType.USB_ENDPOINT_TYPE_INTERRUPT:
85-
throw new NotImplementedException("USB_ENDPOINT_TYPE_INTERRUPT");
8685
// TODO: requires queuing reuests and handling USBIP_CMD_UNLINK
8786
// urb.type = UsbSupTransferType.USBSUP_TRANSFER_TYPE_INTR;
8887
// break;
88+
throw new NotImplementedException("USB_ENDPOINT_TYPE_INTERRUPT");
8989
case UsbEndpointType.USB_ENDPOINT_TYPE_ISOCHRONOUS:
9090
throw new NotImplementedException("USB_ENDPOINT_TYPE_ISOCHRONOUS");
9191
}

UsbIpServer/ConnectedClient.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ You should have received a copy of the GNU General Public License
1616
along with this program. If not, see <https://www.gnu.org/licenses/>.
1717
*/
1818

19-
using Microsoft.Extensions.DependencyInjection;
20-
using Microsoft.Extensions.Logging;
2119
using System;
2220
using System.Buffers.Binary;
2321
using System.Diagnostics.CodeAnalysis;
@@ -27,6 +25,8 @@ You should have received a copy of the GNU General Public License
2725
using System.Text;
2826
using System.Threading;
2927
using System.Threading.Tasks;
28+
using Microsoft.Extensions.DependencyInjection;
29+
using Microsoft.Extensions.Logging;
3030
using UsbIpServer.Interop;
3131
using static UsbIpServer.Interop.UsbIp;
3232
using static UsbIpServer.Tools;

UsbIpServer/DeviceFile.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ You should have received a copy of the GNU General Public License
1616
along with this program. If not, see <https://www.gnu.org/licenses/>.
1717
*/
1818

19-
using Microsoft.Win32.SafeHandles;
2019
using System;
2120
using System.ComponentModel;
2221
using System.IO;
2322
using System.Net;
2423
using System.Runtime.InteropServices;
2524
using System.Threading;
2625
using System.Threading.Tasks;
26+
using Microsoft.Win32.SafeHandles;
2727
using static UsbIpServer.Interop.WinSDK;
2828

2929
namespace UsbIpServer
@@ -75,7 +75,7 @@ void OnCompletion(uint errorCode, uint numBytes, NativeOverlapped* nativeOverlap
7575
}
7676

7777
var nativeOverlapped = overlapped.Pack(OnCompletion, new object?[] { input, output });
78-
fixed (byte *pInput = input, pOutput = output)
78+
fixed (byte* pInput = input, pOutput = output)
7979
{
8080
if (!NativeMethods.DeviceIoControl(handle, ioControlCode, (IntPtr)pInput, (uint)(input?.Length ?? 0),
8181
(IntPtr)pOutput, (uint)(output?.Length ?? 0), out var bytesReturned, (IntPtr)nativeOverlapped))

UsbIpServer/ExportedDevice.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ namespace UsbIpServer
3636
sealed class ExportedDevice
3737
{
3838
public string Path { get; set; } = string.Empty;
39-
public string BusId { get => $"{BusNum}-{DevNum}"; }
39+
public string BusId => $"{BusNum}-{DevNum}";
4040
public uint BusNum { get; set; }
4141
public uint DevNum { get; set; }
4242
public Linux.UsbDeviceSpeed Speed { get; set; }
@@ -197,7 +197,7 @@ public static async Task<ExportedDevice[]> GetAll(CancellationToken cancellation
197197
await hubFile.IoControlAsync(IoControl.IOCTL_USB_GET_NODE_CONNECTION_INFORMATION_EX, buf, buf);
198198
BytesToStruct(buf, 0, out data);
199199

200-
var exportedDevice = new ExportedDevice()
200+
var exportedDevice = new ExportedDevice()
201201
{
202202
Path = instanceId,
203203
BusNum = hubNum,

UsbIpServer/Interop/VBoxUsb.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,13 +91,13 @@ public struct UsbFilterField
9191
[StructLayout(LayoutKind.Sequential, Pack = 4)]
9292
public struct UsbFilter
9393
{
94-
private uint u32Magic;
95-
private UsbFilterType enmType;
94+
uint u32Magic;
95+
UsbFilterType enmType;
9696
[MarshalAs(UnmanagedType.ByValArray, SizeConst = (int)UsbFilterIdx.END)]
9797
public UsbFilterField[] aFields;
98-
private readonly uint offCurEnd;
98+
readonly uint offCurEnd;
9999
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)]
100-
private byte[] achStrTab;
100+
byte[] achStrTab;
101101

102102
public static UsbFilter Create(UsbFilterType type)
103103
{
@@ -160,7 +160,7 @@ public struct UsbSupGetDevMon
160160
[StructLayout(LayoutKind.Sequential, Pack = 1)]
161161
public struct UsbSupClaimDev
162162
{
163-
private readonly byte bInterfaceNumber;
163+
readonly byte bInterfaceNumber;
164164
[MarshalAs(UnmanagedType.U1)]
165165
public bool fClaimed;
166166
}

UsbIpServer/Interop/WinSDK.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ You should have received a copy of the GNU General Public License
1616
along with this program. If not, see <https://www.gnu.org/licenses/>.
1717
*/
1818

19-
using Microsoft.Win32.SafeHandles;
2019
using System;
2120
using System.IO;
2221
using System.Runtime.InteropServices;
22+
using Microsoft.Win32.SafeHandles;
2323
using static UsbIpServer.Interop.Usb;
2424

2525
namespace UsbIpServer.Interop
@@ -120,7 +120,7 @@ public struct SpDeviceInterfaceData
120120
public uint cbSize;
121121
public Guid interfaceClassGuid;
122122
public uint flags;
123-
private readonly UIntPtr reserved;
123+
readonly UIntPtr reserved;
124124
}
125125

126126
/// <summary>WinSDK: SetupAPI.h: SP_DEVINFO_DATA</summary>
@@ -130,7 +130,7 @@ public struct SpDevInfoData
130130
public uint cbSize;
131131
public Guid ClassGuid;
132132
public uint DevInst;
133-
private readonly UIntPtr Reserved;
133+
readonly UIntPtr Reserved;
134134
}
135135

136136
public static class NativeMethods

UsbIpServer/Program.cs

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,24 +16,26 @@ You should have received a copy of the GNU General Public License
1616
along with this program. If not, see <https://www.gnu.org/licenses/>.
1717
*/
1818

19-
using Microsoft.Extensions.CommandLineUtils;
20-
using Microsoft.Extensions.DependencyInjection;
21-
using Microsoft.Extensions.Hosting;
2219
using System;
2320
using System.IO;
2421
using System.Linq;
2522
using System.Reflection;
23+
using Microsoft.Extensions.CommandLineUtils;
24+
using Microsoft.Extensions.DependencyInjection;
25+
using Microsoft.Extensions.Hosting;
26+
27+
[assembly: CLSCompliant(true)]
2628

2729
namespace UsbIpServer
2830
{
2931
static class Program
3032
{
31-
static string Product { get => Assembly.GetExecutingAssembly().GetCustomAttribute<AssemblyProductAttribute>()!.Product; }
32-
static string Copyright { get => Assembly.GetExecutingAssembly().GetCustomAttribute<AssemblyCopyrightAttribute>()!.Copyright; }
33+
static string Product => Assembly.GetExecutingAssembly().GetCustomAttribute<AssemblyProductAttribute>()!.Product;
34+
static string Copyright => Assembly.GetExecutingAssembly().GetCustomAttribute<AssemblyCopyrightAttribute>()!.Copyright;
3335

3436
static void ShowCopyright()
3537
{
36-
Console.WriteLine($@"{Product} {GitVersionInformation.FullSemVer}
38+
Console.WriteLine($@"{Product} {GitVersionInformation.MajorMinorPatch}
3739
{Copyright}
3840
3941
This program is free software: you can redistribute it and/or modify
@@ -57,7 +59,7 @@ static int Main(string[] args)
5759
{
5860
Name = Path.ChangeExtension(Path.GetFileName(Assembly.GetExecutingAssembly().Location), "exe"),
5961
};
60-
app.VersionOption("-v|--version", GitVersionInformation.FullSemVer, GitVersionInformation.InformationalVersion);
62+
app.VersionOption("-v|--version", GitVersionInformation.MajorMinorPatch, GitVersionInformation.InformationalVersion);
6163

6264
void DefaultCmdLine(CommandLineApplication cmd)
6365
{
@@ -69,10 +71,12 @@ void DefaultCmdLine(CommandLineApplication cmd)
6971

7072
DefaultCmdLine(app);
7173
app.OptionHelp.ShowInHelpText = true;
72-
app.Command("license", (cmd) => {
74+
app.Command("license", (cmd) =>
75+
{
7376
cmd.Description = "Display license information";
7477
DefaultCmdLine(cmd);
75-
cmd.OnExecute(() => {
78+
cmd.OnExecute(() =>
79+
{
7680
ShowCopyright();
7781
return 0;
7882
});
@@ -91,14 +95,16 @@ void DefaultCmdLine(CommandLineApplication cmd)
9195
cmd.Option("-b|--busid=<busid>", "Unbind VBoxUsb.sys from device on <busid>", CommandOptionType.SingleValue);
9296
});
9397
#endif
94-
app.Command("server", (cmd) => {
98+
app.Command("server", (cmd) =>
99+
{
95100
cmd.Description = "Run the server stand-alone on the console";
96101
DefaultCmdLine(cmd);
97102
cmd.Argument("key=value", ".NET configuration override", true);
98103
cmd.OnExecute(() => ExecuteServer(cmd.Arguments.Single().Values.ToArray()));
99104
});
100105

101-
app.OnExecute(() => {
106+
app.OnExecute(() =>
107+
{
102108
app.ShowRootCommandFullNameAndVersion();
103109
app.ShowHint();
104110
return 0;

UsbIpServer/SafeDeviceInfoSetHandle.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ public SafeDeviceInfoSetHandle()
2828
{
2929
}
3030

31-
protected override bool ReleaseHandle() => NativeMethods.SetupDiDestroyDeviceInfoList(handle);
31+
protected override bool ReleaseHandle()
32+
{
33+
return NativeMethods.SetupDiDestroyDeviceInfoList(handle);
34+
}
3235
}
3336
}

UsbIpServer/Server.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ You should have received a copy of the GNU General Public License
1616
along with this program. If not, see <https://www.gnu.org/licenses/>.
1717
*/
1818

19-
using Microsoft.Extensions.DependencyInjection;
20-
using Microsoft.Extensions.Hosting;
21-
using Microsoft.Extensions.Logging;
2219
using System;
2320
using System.Diagnostics.CodeAnalysis;
2421
using System.Net.Sockets;
2522
using System.Threading;
2623
using System.Threading.Tasks;
24+
using Microsoft.Extensions.DependencyInjection;
25+
using Microsoft.Extensions.Hosting;
26+
using Microsoft.Extensions.Logging;
2727
using static UsbIpServer.Interop.UsbIp;
2828

2929
namespace UsbIpServer

0 commit comments

Comments
 (0)