Skip to content

Commit

Permalink
Adjust Publish profile
Browse files Browse the repository at this point in the history
  • Loading branch information
jim60105 committed Feb 21, 2022
1 parent 58e53b3 commit 760d34a
Show file tree
Hide file tree
Showing 8 changed files with 87 additions and 27 deletions.
File renamed without changes.
39 changes: 39 additions & 0 deletions Program.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using Microsoft.Win32;
using Serilog;
using Serilog.Core;
using Serilog.Formatting.Display;
Expand All @@ -20,9 +21,47 @@ static void Main()
.WriteToSimpleAndRichTextBox(new MessageTemplateTextFormatter("{Message} {Exception}\n"))
.CreateLogger();

Task.Run(SetAddRemoveProgramsIcon);

// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
Application.Run(new Form1());
}

#pragma warning disable CS8602 // 可能 null 參考的取值 (dereference)。
private static void SetAddRemoveProgramsIcon()
{
//if (ApplicationDeployment.IsNetworkDeployed && ApplicationDeployment.CurrentDeployment.IsFirstRun)
{
try
{
var iconSourcePath = Path.Combine(System.Windows.Forms.Application.StartupPath, @"YoutubeSegmentDownloader.ico");

if (!File.Exists(iconSourcePath)) return;

var uninstallKey = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Uninstall");
if (uninstallKey == null) return;

var subKeyNames = uninstallKey.GetSubKeyNames();
foreach (var subkeyName in subKeyNames)
{
var myKey = uninstallKey.OpenSubKey(subkeyName, true);
var myValue = myKey.GetValue("DisplayName");
if (myValue != null
&& myValue.ToString() == "Youtube Segment Downloader")
{
myKey.SetValue("DisplayIcon", iconSourcePath);
break;
}
}
}
catch (Exception e)
{
Log.Logger.Error(e.Message);
}
}
}
#pragma warning restore CS8602 // 可能 null 參考的取值 (dereference)。
}

30 changes: 18 additions & 12 deletions Properties/PublishProfiles/ClickOnceProfile.pubxml
Original file line number Diff line number Diff line change
Expand Up @@ -4,39 +4,45 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ApplicationRevision>2</ApplicationRevision>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.*</ApplicationVersion>
<BootstrapperEnabled>True</BootstrapperEnabled>
<Configuration>Release</Configuration>
<CreateWebPageOnPublish>True</CreateWebPageOnPublish>
<DisallowUrlActivation>False</DisallowUrlActivation>
<CreateDesktopShortcut>True</CreateDesktopShortcut>
<CreateWebPageOnPublish>False</CreateWebPageOnPublish>
<DisallowUrlActivation>True</DisallowUrlActivation>
<ErrorReportUrl>https://github.com/jim60105/YoutubeSegmentDownloader/issues</ErrorReportUrl>
<ExcludeDeploymentUrl>True</ExcludeDeploymentUrl>
<GenerateManifests>True</GenerateManifests>
<Install>True</Install>
<InstallFrom>Disk</InstallFrom>
<InstallFrom>Web</InstallFrom>
<InstallUrl>https://github.com/jim60105/YoutubeSegmentDownloader/raw/setup/</InstallUrl>
<IsRevisionIncremented>True</IsRevisionIncremented>
<IsWebBootstrapper>False</IsWebBootstrapper>
<MapFileExtensions>False</MapFileExtensions>
<IsWebBootstrapper>True</IsWebBootstrapper>
<MapFileExtensions>True</MapFileExtensions>
<OpenBrowserOnPublish>False</OpenBrowserOnPublish>
<Platform>Any CPU</Platform>
<PublishDir>bin\Release\net6.0-windows\publish\</PublishDir>
<PublishUrl>bin\Release\net6.0-windows\publish\</PublishUrl>
<ProductName>Youtube Segment Downloader</ProductName>
<PublishDir>bin\Release\net6.0-windows\win-x64\app.publish\</PublishDir>
<PublishUrl>bin\Release\net6.0-windows\win-x64\app.publish\</PublishUrl>
<PublishProtocol>ClickOnce</PublishProtocol>
<PublishReadyToRun>True</PublishReadyToRun>
<PublishReadyToRun>False</PublishReadyToRun>
<PublishSingleFile>True</PublishSingleFile>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<SelfContained>False</SelfContained>
<SignatureAlgorithm>(無)</SignatureAlgorithm>
<SignManifests>False</SignManifests>
<SuiteName>Youtube Segment Downloader</SuiteName>
<SupportUrl>https://github.com/jim60105/YoutubeSegmentDownloader</SupportUrl>
<TargetFramework>net6.0-windows</TargetFramework>
<UpdateEnabled>False</UpdateEnabled>
<UpdateEnabled>True</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateRequired>False</UpdateRequired>
<WebPageFileName>Publish.html</WebPageFileName>
<History>True|2022-02-21T10:39:30.5249061Z;</History>
</PropertyGroup>
<ItemGroup>
<BootstrapperPackage Include="Microsoft.NetCore.DesktopRuntime.6.0.x64">
<Install>True</Install>
<Install>true</Install>
<ProductName>.NET Desktop 執行階段 6.0.1 (x64)</ProductName>
</BootstrapperPackage>
</ItemGroup>
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# YoutubeSegmentDownloader
43 changes: 28 additions & 15 deletions YoutubeSegmentDownloader.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,28 @@
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework>
<RuntimeIdentifiers>win-x64</RuntimeIdentifiers>
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
<ApplicationIcon>assets\256.ico</ApplicationIcon>
<ApplicationIcon>YoutubeSegmentDownloader.ico</ApplicationIcon>
<PackageIcon>256.png</PackageIcon>
<NoWin32Manifest>true</NoWin32Manifest>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageProjectUrl>https://github.com/jim60105/YoutubeSegmentDownloader</PackageProjectUrl>
<Copyright>GPL-3.0 License</Copyright>
<Product>Youtube Segment Downloader</Product>
<Company>Youtube Segment Downloader</Company>
<Authors>jim60105</Authors>
<RepositoryUrl>https://github.com/jim60105/YoutubeSegmentDownloader.git</RepositoryUrl>
<PackageLicenseFile>E:\repos\YoutubeSegmentDownload\LICENSE</PackageLicenseFile>
<PackageRequireLicenseAcceptance>True</PackageRequireLicenseAcceptance>
<StartupObject>YoutubeSegmentDownloader.Program</StartupObject>
<PlatformTarget>x64</PlatformTarget>
</PropertyGroup>

<ItemGroup>
<None Remove="assets\256.png" />
</ItemGroup>

<ItemGroup>
<Content Include="assets\256.ico">
<Content Include="YoutubeSegmentDownloader.ico">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
Expand All @@ -27,14 +36,6 @@
<PackageReference Include="YoutubeDLSharp" Version="0.4.1" />
</ItemGroup>

<ItemGroup>
<Content Include="assets\256.png">
<Pack>True</Pack>
<PackagePath>\</PackagePath>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>

<ItemGroup>
<Compile Update="Properties\Settings.Designer.cs">
<DesignTimeSharedInput>True</DesignTimeSharedInput>
Expand All @@ -44,10 +45,22 @@
</ItemGroup>

<ItemGroup>
<None Update="assets\256.png">
<Pack>True</Pack>
<PackagePath>\</PackagePath>
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
</None>
<None Update="LICENSE">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<None Update="README.md">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<Pack>True</Pack>
<PackagePath>\</PackagePath>
</None>
</ItemGroup>

</Project>
File renamed without changes.
1 change: 1 addition & 0 deletions YoutubeSegmentDownloader.sln
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{28BC7A00-8813-43CD-9A3A-E7F8E15513B2}"
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
.github\workflows\dotnet.yml = .github\workflows\dotnet.yml
EndProjectSection
EndProject
Global
Expand Down
Binary file removed assets/16.ico
Binary file not shown.

0 comments on commit 760d34a

Please sign in to comment.