Skip to content

Commit

Permalink
build(nuget): try out nuget packaging with appveyor
Browse files Browse the repository at this point in the history
  • Loading branch information
dwmkerr committed May 19, 2018
1 parent 86b96cf commit 311427c
Show file tree
Hide file tree
Showing 12 changed files with 68 additions and 29 deletions.
5 changes: 5 additions & 0 deletions SharpShell/SharpShell/Interop/Shell32.cs
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,11 @@ public static extern int SHCreateDataObject(IntPtr pidlFolder, uint cidl, IntPtr
[DllImport("shell32.dll", CharSet = CharSet.Auto, SetLastError = true)]
public static extern void SHChangeNotify(Int32 wEventId, UInt32 uFlags, IntPtr dwItem1, IntPtr dwItem2);

/// <summary>
/// A file type association has changed. SHCNF_IDLIST must be specified in the uFlags parameter. dwItem1 and dwItem2 are not used and must be NULL. This event should also be sent for registered protocols.
/// </summary>
public static Int32 SHCNE_ASSOCCHANGED = 0x08000000;

public static Guid IID_IQueryAssociations = new Guid("{c46ca590-3c3f-11d2-bee6-0000f805ca57}");
public static Guid IID_IShellFolder = new Guid("000214E6-0000-0000-C000-000000000046");
public static Guid IID_IImageList = new Guid("46EB5926-582E-4017-9FDF-E8998DAA0950");
Expand Down
Binary file modified SharpShell/SharpShell/NativeBridge/SharpShellNativeBridge64.dll
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -570,32 +570,28 @@ private static IEnumerable<string> CreateClassNamesForAssociations(AssociationTy
var fileTypeClasses = new List<string>();

// We've got extensions, but we need the classes for them.
foreach (var association in associations)
foreach (var fileExtension in associations)
{
// Open the file type key.
using (var fileTypeKey = classesKey.OpenSubKey(association))
using (var fileTypeKey = classesKey.OpenSubKey(fileExtension))
{
// If the file type key is null, create it.
if (fileTypeKey == null)
// If the file type key is null, create it. There's no class, so just associate
// with the extension.
if (fileTypeKey == null)
{
classesKey.CreateSubKey(association);
// use the file type key as the class
fileTypeClasses.Add(association);
}
else
{
// Get the default value, this should be the file type class.
var fileTypeClass = fileTypeKey.GetValue(null) as string;
if (fileTypeClass == null || fileTypeClass== String.Empty)
{
fileTypeClasses.Add(association);
}
else
{
// If the file type class is valid, we can return it.
fileTypeClasses.Add(fileTypeClass);
}
classesKey.CreateSubKey(fileExtension);
fileTypeClasses.Add(fileExtension);
continue;
}

// Get the default value, this should be the file type class.
var fileTypeClass = fileTypeKey.GetValue(null) as string;

// If we have a file type class, use that for the association. Otherwise,
// just use the file extension.
fileTypeClasses.Add(string.IsNullOrEmpty(fileTypeClass)
? fileExtension
: fileTypeClass);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,8 @@ internal static void CustomRegisterFunction(Type serverType, RegistrationType re
"being registered, it will not be used by Windows Explorer.");

// Create the overlay key.
using(var overlayKey = overlayIdentifiers.CreateSubKey(" " + serverType.Name))
var identifierKeyName = GetIdentifierKeyName(serverType);
using (var overlayKey = overlayIdentifiers.CreateSubKey(identifierKeyName))
{
// If we don't have the overlay key, we've got a problem.
if(overlayKey == null)
Expand Down Expand Up @@ -271,15 +272,27 @@ internal static void CustomUnregisterFunction(Type serverType, RegistrationType
{
// If we don't have the key, we've got a problem.
if (overlayIdentifiers == null)
throw new InvalidOperationException("Cannot open the ShellIconOverlayIdentifiers key.");

throw new InvalidOperationException("Cannot open the ShellIconOverlayIdentifiers key.");

// Delete the overlay key.
if (overlayIdentifiers.GetSubKeyNames().Any(skn => skn == (" " + serverType.Name)))
overlayIdentifiers.DeleteSubKey(" " + serverType.Name);
var identifierKeyName = GetIdentifierKeyName(serverType);
if (overlayIdentifiers.GetSubKeyNames().Any(skn => skn == identifierKeyName))
overlayIdentifiers.DeleteSubKey(identifierKeyName);
}
}
}

/// <summary>
/// Gets the key name for the overlay handler. Deliberately uses a low ASCII code letter at the
/// beginning to ensure a high-priority key name.
/// </summary>
/// <param name="serverTypeName">The server type name.</param>
/// <returns>The identifier key name for the server type.</returns>
private static string GetIdentifierKeyName(Type serverTypeName)
{
return " " + serverTypeName.Name;
}

/// <summary>
/// Creates the temporary icon file path.
/// </summary>
Expand Down
5 changes: 4 additions & 1 deletion SharpShell/SharpShell/SharpShell.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@
</ItemGroup>
<ItemGroup>
<None Include="Key.snk" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="NativeBridge\SharpShellNativeBridge32.dll" />
Expand All @@ -313,7 +314,9 @@
<DependentUpon>SharpPropertyPage.cs</DependentUpon>
</EmbeddedResource>
</ItemGroup>
<ItemGroup />
<ItemGroup>
<Content Include="SharpShell.nuspec" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>copy "$(TargetDir)SharpShell.*" "$(SolutionDir)..\Build\Core"
Expand Down
20 changes: 20 additions & 0 deletions SharpShell/SharpShell/SharpShell.nuspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata>
<id>$id$</id>
<version>$version$</version>
<title>SharpShell</title>
<authors>Dave Kerr</authors>
<owners>Dave Kerr</owners>
<projectUrl>https://github.com/dwmkerr/sharpshell</projectUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>SharpShell is a framework that lets you build Windows Shell Extensions using the .NET Framework.</description>
<summary>SharpShell is a framework that lets you build Windows Shell Extensions using the .NET Framework.</summary>
<copyright>Copyright © Dave Kerr 2014</copyright>
<tags>Shell,SharpShell,COM,Context Menu,Icon Handler</tags>
<frameworkAssemblies>
<frameworkAssembly assemblyName="System.Windows.Forms" targetFramework="" />
<frameworkAssembly assemblyName="System.Drawing" targetFramework="" />
</frameworkAssemblies>
</metadata>
</package>
6 changes: 4 additions & 2 deletions SharpShell/SharpShell/SharpShellServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ internal static void DoRegister(Type type, RegistrationType registrationType)
// Execute the custom register function, if there is one.
CustomRegisterFunctionAttribute.ExecuteIfExists(type, registrationType);

Shell32.SHChangeNotify(0x08000000, 0, IntPtr.Zero, IntPtr.Zero);
// Notify the shell we've updated associations.
Shell32.SHChangeNotify(Shell32.SHCNE_ASSOCCHANGED, 0, IntPtr.Zero, IntPtr.Zero);
}

/// <summary>
Expand Down Expand Up @@ -110,7 +111,8 @@ internal static void DoUnregister(Type type, RegistrationType registrationType)
// Execute the custom unregister function, if there is one.
CustomUnregisterFunctionAttribute.ExecuteIfExists(type, registrationType);

Shell32.SHChangeNotify(0x08000000, 0, IntPtr.Zero, IntPtr.Zero);
// Notify the shell we've updated associations.
Shell32.SHChangeNotify(Shell32.SHCNE_ASSOCCHANGED, 0, IntPtr.Zero, IntPtr.Zero);
}

/// <summary>
Expand Down
Binary file not shown.
Binary file added Tests/TestData/IconHandlers/SharpShell.all
Binary file not shown.
Binary file added Tests/TestData/IconHandlers/SharpShell.dll
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit 311427c

Please sign in to comment.