mirror of
https://github.com/greenshot/greenshot
synced 2025-08-19 13:10:00 -07:00
Fixed an issue with the build, where MSBuild.Community.Tasks.Targets wasn't found. Also improved the registry reading for the MAPI control.
This commit is contained in:
parent
328e7e569d
commit
2733c6cf26
7 changed files with 33 additions and 21 deletions
|
@ -102,11 +102,14 @@
|
||||||
</Tokens>
|
</Tokens>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup Condition="$(MSBuildProjectName.Contains('Plugin'))">
|
||||||
<PackageReference Include="MSBuildTasks" Version="1.5.0.235" GeneratePathProperty="true"/>
|
<PackageReference Include="MSBuildTasks" Version="1.5.0.235" GeneratePathProperty="true" DevelopmentDependency="true" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<PropertyGroup Condition="'$(PkgTools_MSBuildTasks)' == ''">
|
||||||
|
<PkgTools_MSBuildTasks>$(userprofile)\.nuget\packages\msbuildtasks\1.5.0.235\tools\</PkgTools_MSBuildTasks>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
<Import Project="$(PkgTools_MSBuildTasks)MSBuild.Community.Tasks.Targets" Condition="Exists('$(ProjectDir)$(ProjectName).Credentials.template')"/>
|
<Import Project="$(PkgTools_MSBuildTasks)MSBuild.Community.Tasks.Targets" Condition="$(MSBuildProjectName.Contains('Plugin'))"/>
|
||||||
|
|
||||||
<Target Name="ProcessTemplates" BeforeTargets="PrepareForBuild" Condition="Exists('$(ProjectDir)$(ProjectName).Credentials.template')">
|
<Target Name="ProcessTemplates" BeforeTargets="PrepareForBuild" Condition="Exists('$(ProjectDir)$(ProjectName).Credentials.template')">
|
||||||
<Message Text="Processing: $(ProjectDir)$(ProjectName).Credentials.template" Importance="high"/>
|
<Message Text="Processing: $(ProjectDir)$(ProjectName).Credentials.template" Importance="high"/>
|
||||||
|
|
|
@ -46,6 +46,13 @@
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Update="MSBuildTasks" Version="1.5.0.235">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
</PackageReference>
|
||||||
|
</ItemGroup>
|
||||||
<UsingTask TaskName="SetEnvironmentVariableTask" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll">
|
<UsingTask TaskName="SetEnvironmentVariableTask" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll">
|
||||||
|
|
||||||
<ParameterGroup>
|
<ParameterGroup>
|
||||||
|
|
|
@ -174,7 +174,7 @@ namespace Greenshot.Helpers {
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void ShowDialog() {
|
public void ShowDialog() {
|
||||||
// Create the mail message in an STA thread
|
// Create the mail message in an STA thread
|
||||||
var thread = new Thread(_ShowMail)
|
var thread = new Thread(ShowMail)
|
||||||
{
|
{
|
||||||
IsBackground = true,
|
IsBackground = true,
|
||||||
Name = "Create MAPI mail"
|
Name = "Create MAPI mail"
|
||||||
|
@ -202,7 +202,7 @@ namespace Greenshot.Helpers {
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Sends the mail message.
|
/// Sends the mail message.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void _ShowMail() {
|
private void ShowMail() {
|
||||||
var message = new MapiHelperInterop.MapiMessage();
|
var message = new MapiHelperInterop.MapiMessage();
|
||||||
|
|
||||||
using var interopRecipients = Recipients.GetInteropRepresentation();
|
using var interopRecipients = Recipients.GetInteropRepresentation();
|
||||||
|
@ -215,7 +215,7 @@ namespace Greenshot.Helpers {
|
||||||
// Check if we need to add attachments
|
// Check if we need to add attachments
|
||||||
if (Files.Count > 0) {
|
if (Files.Count > 0) {
|
||||||
// Add attachments
|
// Add attachments
|
||||||
message.Files = _AllocAttachments(out message.FileCount);
|
message.Files = AllocAttachments(out message.FileCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Signal the creating thread (make the remaining code async)
|
// Signal the creating thread (make the remaining code async)
|
||||||
|
@ -227,7 +227,7 @@ namespace Greenshot.Helpers {
|
||||||
|
|
||||||
if (Files.Count > 0) {
|
if (Files.Count > 0) {
|
||||||
// Deallocate the files
|
// Deallocate the files
|
||||||
_DeallocFiles(message);
|
DeallocFiles(message);
|
||||||
}
|
}
|
||||||
MAPI_CODES errorCode = (MAPI_CODES)Enum.ToObject(typeof(MAPI_CODES), error);
|
MAPI_CODES errorCode = (MAPI_CODES)Enum.ToObject(typeof(MAPI_CODES), error);
|
||||||
|
|
||||||
|
@ -245,14 +245,14 @@ namespace Greenshot.Helpers {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Recipients = new RecipientCollection();
|
Recipients = new RecipientCollection();
|
||||||
_ShowMail();
|
ShowMail();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Deallocates the files in a message.
|
/// Deallocates the files in a message.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="message">The message to deallocate the files from.</param>
|
/// <param name="message">The message to deallocate the files from.</param>
|
||||||
private void _DeallocFiles(MapiHelperInterop.MapiMessage message) {
|
private void DeallocFiles(MapiHelperInterop.MapiMessage message) {
|
||||||
if (message.Files != IntPtr.Zero) {
|
if (message.Files != IntPtr.Zero) {
|
||||||
Type fileDescType = typeof(MapiFileDescriptor);
|
Type fileDescType = typeof(MapiFileDescriptor);
|
||||||
int fsize = Marshal.SizeOf(fileDescType);
|
int fsize = Marshal.SizeOf(fileDescType);
|
||||||
|
@ -274,7 +274,7 @@ namespace Greenshot.Helpers {
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="fileCount"></param>
|
/// <param name="fileCount"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
private IntPtr _AllocAttachments(out int fileCount) {
|
private IntPtr AllocAttachments(out int fileCount) {
|
||||||
fileCount = 0;
|
fileCount = 0;
|
||||||
if (Files == null) {
|
if (Files == null) {
|
||||||
return IntPtr.Zero;
|
return IntPtr.Zero;
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\GreenshotPlugin\GreenshotPlugin.csproj" />
|
<ProjectReference Include="..\GreenshotPlugin\GreenshotPlugin.csproj" />
|
||||||
<PackageReference Include="Dapplo.Jira" version="1.1.21" />
|
<PackageReference Include="Dapplo.Jira" version="1.1.38" />
|
||||||
<PackageReference Include="Dapplo.Jira.SvgWinForms" Version="1.1.21" />
|
<PackageReference Include="Dapplo.Jira.SvgWinForms" Version="1.1.38" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
|
@ -20,6 +20,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using Microsoft.Win32;
|
||||||
|
|
||||||
namespace GreenshotPlugin.Core {
|
namespace GreenshotPlugin.Core {
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -27,16 +28,16 @@ namespace GreenshotPlugin.Core {
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static class EmailConfigHelper {
|
public static class EmailConfigHelper {
|
||||||
|
|
||||||
public static string GetMapiClient() => RegistryHelper.ReadLocalMachineSoftwareKey(@"Clients\Mail");
|
public static string GetMapiClient() => Registry.LocalMachine.ReadKey64Or32(@"Clients\Mail");
|
||||||
|
|
||||||
public static bool HasMapi()
|
public static bool HasMapi()
|
||||||
{
|
{
|
||||||
var value = RegistryHelper.ReadLocalMachineSoftwareKey(@"Microsoft\Windows Messaging Subsystem", "MAPI", "0");
|
var value = Registry.LocalMachine.ReadKey64Or32(@"Microsoft\Windows Messaging Subsystem", "MAPI", "0");
|
||||||
return "1".Equals(value);
|
return "1".Equals(value);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string GetOutlookExePath() => RegistryHelper.ReadLocalMachineSoftwareKey(@"Microsoft\Windows\CurrentVersion\App Paths\OUTLOOK.EXE");
|
public static string GetOutlookExePath() => Registry.LocalMachine.ReadKey64Or32(@"Microsoft\Windows\CurrentVersion\App Paths\OUTLOOK.EXE");
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Check if Outlook is installed
|
/// Check if Outlook is installed
|
||||||
|
|
|
@ -27,22 +27,23 @@ namespace GreenshotPlugin.Core
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A helper class for accessing the registry
|
/// A helper class for accessing the registry
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static class RegistryHelper
|
public static class RegistryKeyExtensions
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Retrieve a registry value
|
/// Retrieve a registry value
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <param name="registryKey">RegistryKey like Registry.LocalMachine</param>
|
||||||
/// <param name="keyName">string with the name of the key</param>
|
/// <param name="keyName">string with the name of the key</param>
|
||||||
/// <param name="value">string with the name of the value below the key, null will retrieve the default</param>
|
/// <param name="value">string with the name of the value below the key, null will retrieve the default</param>
|
||||||
/// <param name="defaultValue">string with the default value to return</param>
|
/// <param name="defaultValue">string with the default value to return</param>
|
||||||
/// <returns>string with the value</returns>
|
/// <returns>string with the value</returns>
|
||||||
public static string ReadLocalMachineSoftwareKey(string keyName, string value = null, string defaultValue = null)
|
public static string ReadKey64Or32(this RegistryKey registryKey, string keyName, string value = null, string defaultValue = null)
|
||||||
{
|
{
|
||||||
string result = null;
|
string result = null;
|
||||||
value ??= string.Empty;
|
value ??= string.Empty;
|
||||||
if (Environment.Is64BitOperatingSystem)
|
if (Environment.Is64BitOperatingSystem)
|
||||||
{
|
{
|
||||||
using var key = Registry.LocalMachine.OpenSubKey($@"SOFTWARE\{keyName}", false);
|
using var key = registryKey.OpenSubKey($@"SOFTWARE\{keyName}", false);
|
||||||
|
|
||||||
if (key != null)
|
if (key != null)
|
||||||
{
|
{
|
||||||
|
@ -52,7 +53,7 @@ namespace GreenshotPlugin.Core
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(result))
|
if (string.IsNullOrEmpty(result))
|
||||||
{
|
{
|
||||||
using var key = Registry.LocalMachine.OpenSubKey($@"SOFTWARE\wow6432node\{keyName}", false);
|
using var key = registryKey.OpenSubKey($@"SOFTWARE\wow6432node\{keyName}", false);
|
||||||
|
|
||||||
if (key != null)
|
if (key != null)
|
||||||
{
|
{
|
|
@ -13,9 +13,9 @@
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Dapplo.HttpExtensions.JsonNet" Version="1.0.3" />
|
<PackageReference Include="Dapplo.HttpExtensions.JsonNet" Version="1.0.8" />
|
||||||
<PackageReference Include="log4net" version="2.0.12" />
|
<PackageReference Include="log4net" version="2.0.12" />
|
||||||
<PackageReference Include="Svg" Version="3.1.1" />
|
<PackageReference Include="Svg" Version="3.2.3" />
|
||||||
<Reference Include="Accessibility" />
|
<Reference Include="Accessibility" />
|
||||||
<Reference Include="CustomMarshalers" />
|
<Reference Include="CustomMarshalers" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue