Skip to content

Commit

Permalink
Ported to NetStandard2
Browse files Browse the repository at this point in the history
  • Loading branch information
falahati committed Apr 18, 2020
1 parent 21b614e commit cdbc52d
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 113 deletions.
File renamed without changes
36 changes: 0 additions & 36 deletions StartupHelper/Properties/AssemblyInfo.cs

This file was deleted.

87 changes: 40 additions & 47 deletions StartupHelper/StartupHelper.csproj
Original file line number Diff line number Diff line change
@@ -1,57 +1,50 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{5D71AD0C-A697-4CB1-B7A4-8395BA7D6D4C}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>StartupHelper</RootNamespace>
<AssemblyName>StartupHelper</AssemblyName>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
<TargetFrameworks>netstandard2.0;net4</TargetFrameworks>
<Version>1.0.3.4</Version>
<Company>falahati.net</Company>
<Description>A .Net library to add or remove your program to the startup list as well as detecting the startup session. Supporting Windows XP+ with and without administrator rights.</Description>
<Authors>Soroush Falahati</Authors>
<Copyright>Copyright © Soroush Falahati 2016-2020 (falahati.net)</Copyright>
<Platforms>AnyCPU</Platforms>
<Product>StartupHelper</Product>
<PackageProjectUrl>https://github.com/falahati/StartupHelper</PackageProjectUrl>
<PackageLicenseUrl>https://github.com/falahati/StartupHelper/blob/master/LICENSE</PackageLicenseUrl>
<PackageIconUrl>https://github.com/falahati/StartupHelper/blob/master/StartupHelper/Icon.png?raw=true</PackageIconUrl>
<IncludeSymbols>true</IncludeSymbols>
<IncludeSource>true</IncludeSource>
<PlatformTarget>AnyCPU</PlatformTarget>
<Title>Startup Helper (Win XP+)</Title>
<PackageId>StartupHelper</PackageId>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
<DocumentationFile>
</DocumentationFile>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<BumpLabel>dev</BumpLabel>
<BumpLabelDigits>4</BumpLabelDigits>
<OutputPath>..\Debug</OutputPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
<DocumentationFile>bin\Release\StartupHelper.xml</DocumentationFile>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<BumpRevision>True</BumpRevision>
<BumpResetLabel>dev</BumpResetLabel>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<OutputPath>..\Release</OutputPath>
<DocumentationFile>..\Release\StartupHelper.xml</DocumentationFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.Win32.TaskScheduler, Version=2.5.19.0, Culture=neutral, PublicKeyToken=0d013ddd5178a2ae, processorArchitecture=MSIL">
<HintPath>..\packages\TaskScheduler.2.5.19\lib\net20\Microsoft.Win32.TaskScheduler.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Xml" />
<PackageReference PrivateAssets="all" Include="MSBump" Version="2.3.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="TaskScheduler" Version="2.8.18" />
</ItemGroup>
<ItemGroup>
<Compile Include="RegistrationScope.cs" />
<Compile Include="StartupManager.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="StartupProviders.cs" />
<Content Include="readme.txt">
<Pack>true</Pack>
<PackagePath>\</PackagePath>
</Content>
<Content Include="Icon.png">
<Pack>true</Pack>
<PackagePath>\</PackagePath>
</Content>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
<None Include="readme.txt" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(AssemblyName).targets" />
</Project>
17 changes: 0 additions & 17 deletions StartupHelper/StartupHelper.nuspec

This file was deleted.

13 changes: 6 additions & 7 deletions StartupHelper/StartupManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public StartupManager(string name, RegistrationScope scope)
/// rights
/// </param>
public StartupManager(string name, RegistrationScope scope, bool needsAdminPrivileges)
: this(Assembly.GetEntryAssembly().Location, name, scope, needsAdminPrivileges)
: this(Assembly.GetEntryAssembly()?.Location, name, scope, needsAdminPrivileges)
{
FixWorkingDirectory();
}
Expand Down Expand Up @@ -184,7 +184,7 @@ public StartupManager(string applicationImage, string name, RegistrationScope sc
public StartupManager(string applicationImage, string name, RegistrationScope scope, bool needsAdminPrivileges,
StartupProviders provider, string startupSpecialArgument)
{
if (!File.Exists(applicationImage))
if (string.IsNullOrEmpty(applicationImage) || !File.Exists(applicationImage))
{
throw new ArgumentException("File doesn't exist.", nameof(applicationImage));
}
Expand Down Expand Up @@ -233,8 +233,7 @@ public static bool IsElevated
get
{
var currentUser = WindowsIdentity.GetCurrent();
return currentUser != null &&
new WindowsPrincipal(currentUser).IsInRole(WindowsBuiltInRole.Administrator);
return new WindowsPrincipal(currentUser).IsInRole(WindowsBuiltInRole.Administrator);
}
}

Expand Down Expand Up @@ -442,7 +441,7 @@ public bool Register(string arguments = null)
: TaskRunLevel.LUA;
if (RegistrationScope == RegistrationScope.Local)
{
taskTrigger.UserId = WindowsIdentity.GetCurrent()?.Name;
taskTrigger.UserId = WindowsIdentity.GetCurrent().Name;
}
}
else
Expand All @@ -460,7 +459,7 @@ public bool Register(string arguments = null)
else
{
newTask.Principal.LogonType = TaskLogonType.InteractiveToken;
newTask.Principal.UserId = WindowsIdentity.GetCurrent()?.Name;
newTask.Principal.UserId = WindowsIdentity.GetCurrent().Name;
}
newTask.Actions.Add(taskAction);
newTask.Triggers.Add(taskTrigger);
Expand Down Expand Up @@ -507,7 +506,7 @@ private static bool IsCurrentUser(string username)
try
{
return ((SecurityIdentifier) (new NTAccount(username).Translate(typeof (SecurityIdentifier)))) ==
WindowsIdentity.GetCurrent()?.User;
WindowsIdentity.GetCurrent().User;
}
catch
{
Expand Down
4 changes: 0 additions & 4 deletions StartupHelper/packages.config

This file was deleted.

2 changes: 0 additions & 2 deletions build.ps1

This file was deleted.

0 comments on commit cdbc52d

Please sign in to comment.