Skip to content

Commit

Permalink
- Replaced with Post-build event
Browse files Browse the repository at this point in the history
  • Loading branch information
KoalaBear84 committed Mar 24, 2021
1 parent 777919f commit 8c7673e
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 15 deletions.
13 changes: 12 additions & 1 deletion HAClimateDeskband/HAClimateDeskband.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<OutputPath>..\HAClimateDeskBand-win-x64\</OutputPath>
<DefineConstants>TRACE;DESKBAND_WINFORMS</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
Expand Down Expand Up @@ -134,4 +134,15 @@
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(SolutionDir)\BuildCommon.targets" />
<PropertyGroup>
<PostBuildEvent>if $(ConfigurationName) == Release (
$(ILMergeConsolePath) /out:$(OutDir)HAClimateDeskband-merged.dll $(OutDir)HAClimateDeskband.dll $(OutDir)Newtonsoft.Json.dll $(OutDir)OxyPlot.dll $(OutDir)OxyPlot.WindowsForms.dll
del /F /Q "$(OutDir)HAClimateDeskband.dll"
del /F /Q "$(OutDir)HAClimateDeskband.pdb"
del /F /Q "$(OutDir)Newtonsoft.Json.dll"
del /F /Q "$(OutDir)OxyPlot.dll"
del /F /Q "$(OutDir)OxyPlot.WindowsForms.dll"
del /F /Q "$(OutDir)HAClimateDeskband-merged.pdb"
)</PostBuildEvent>
</PropertyGroup>
</Project>
16 changes: 12 additions & 4 deletions HAClimateDeskbandInstaller/HAClimateDeskbandInstaller.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<OutputPath>..\HAClimateDeskBand-win-x64\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
Expand Down Expand Up @@ -66,9 +66,9 @@
<None Include="app.manifest" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="..\HAClimateDeskBand-win-x64\HAClimateDeskband.dll">
<Link>Resources\HAClimateDeskband.dll</Link>
</EmbeddedResource>
<Content Include="..\HAClimateDeskBand-win-x64\HAClimateDeskband-merged.dll">
<Link>Resources\HAClimateDeskband-merged.dll</Link>
</Content>
<Content Include="Resources\HomeAssistant.ico" />
</ItemGroup>
<ItemGroup>
Expand All @@ -78,4 +78,12 @@
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(SolutionDir)\BuildCommon.targets" />
<PropertyGroup>
<PostBuildEvent>
</PostBuildEvent>
</PropertyGroup>
<PropertyGroup>
<PreBuildEvent>
</PreBuildEvent>
</PropertyGroup>
</Project>
20 changes: 10 additions & 10 deletions HAClimateDeskbandInstaller/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace HAClimateDeskbandInstaller
class Program
{
private const string InstallerExecutableName = "HAClimateDeskbandInstaller.exe";
private const string DllName = "HAClimateDeskband.dll";
private const string DllName = "HAClimateDeskband-merged.dll";
static Guid UninstallGuid = new Guid(@"2d0e746f-e2ae-4c2c-9040-5c5a715e7a8a");

class InstallInfo
Expand Down Expand Up @@ -88,7 +88,7 @@ static void Install(InstallInfo info)
// Register assemblies
foreach (string filename in info.FilesToRegister)
{
string targetFilePath = Path.Combine(info.TargetPath, filename);
string targetFilePath = Path.Combine(info.TargetPath, filename.Replace("-merged", string.Empty));
Console.Write($"Registering {filename}.. ");
RegisterDLL(targetFilePath, true, false);
Console.WriteLine("OK.");
Expand All @@ -114,11 +114,11 @@ static void Install(InstallInfo info)

private static void CopyFiles(InstallInfo info)
{
foreach (string item in info.FilesToCopy)
foreach (string filename in info.FilesToCopy)
{
string targetFilePath = Path.Combine(info.TargetPath, item);
Console.Write($"Copying {item}.. ");
WriteEmbeddedResourceToFile(item, targetFilePath);
string targetFilePath = Path.Combine(info.TargetPath, filename.Replace("-merged", string.Empty));
Console.Write($"Copying {filename}.. ");
WriteEmbeddedResourceToFile(filename, targetFilePath);
Console.WriteLine("OK.");
}
}
Expand All @@ -141,7 +141,7 @@ static bool RollBack(InstallInfo info)
// Unregister assembly
foreach (string item in info.FilesToRegister)
{
string targetFilePath = Path.Combine(info.TargetPath, item);
string targetFilePath = Path.Combine(info.TargetPath, item.Replace("-merged", string.Empty));
RegisterDLL(targetFilePath, false, true);
RegisterDLL(targetFilePath, true, true);
}
Expand All @@ -151,13 +151,13 @@ static bool RollBack(InstallInfo info)
restartExplorer.Execute(() =>
{
// Remove files
foreach (string item in info.FilesToCopy)
foreach (string filename in info.FilesToCopy)
{
string targetFilePath = Path.Combine(info.TargetPath, item);
string targetFilePath = Path.Combine(info.TargetPath, filename.Replace("-merged", string.Empty));

if (File.Exists(targetFilePath))
{
Console.Write($"Deleting {item}.. ");
Console.Write($"Deleting {filename}.. ");
File.Delete(targetFilePath);
Console.WriteLine("OK.");
}
Expand Down

0 comments on commit 8c7673e

Please sign in to comment.