Skip to content

Commit 2cf55a3

Browse files
committed
Standalone build
1 parent 9a3cabb commit 2cf55a3

5 files changed

Lines changed: 18 additions & 7 deletions

File tree

.github/workflows/build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ jobs:
9090
- name: Build solution
9191
run: dotnet build CanonSDK.sln --configuration Release --no-restore
9292

93-
- name: Publish Canon.API
94-
run: dotnet publish Canon.API --configuration Release --output ./publish --no-build
93+
- name: Publish Canon.API as standalone executable
94+
run: dotnet publish Canon.API/Canon.API.csproj --configuration Release --runtime win-x64 --self-contained true -p:PublishSingleFile=true --output ./publish
9595

9696
- name: Create release package
9797
run: |

Canon.API/Canon.API.csproj

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,18 @@
55
<Nullable>enable</Nullable>
66
<ImplicitUsings>enable</ImplicitUsings>
77
<PlatformTarget>x64</PlatformTarget>
8-
8+
99
<!-- Assembly Version Configuration -->
1010
<AssemblyVersion>1.0.0.8</AssemblyVersion>
1111
<FileVersion>1.0.0.8</FileVersion>
1212
<Version>1.0.0.8</Version>
13+
14+
<!-- Self-Contained Single-File Deployment -->
15+
<PublishSingleFile>true</PublishSingleFile>
16+
<SelfContained>true</SelfContained>
17+
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
18+
<IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>
19+
<EnableCompressionInSingleFile>true</EnableCompressionInSingleFile>
1320
</PropertyGroup>
1421

1522
<ItemGroup>

Canon.API/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
AutoUpdater.RunUpdateAsAdmin = false; // Disable admin requirement
4242

4343
// Set download path to application directory to avoid temp folder permission issues
44-
var appDirectory = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
44+
var appDirectory = AppContext.BaseDirectory;
4545
AutoUpdater.DownloadPath = appDirectory;
4646
AutoUpdater.InstallationPath = appDirectory;
4747

Canon.Core/Canon.Core.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,13 @@
1010
<ItemGroup>
1111
<None Include="..\EDSDK\EDSDK.dll" Link="EDSDK.dll">
1212
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
13+
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
14+
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
1315
</None>
1416
<None Include="..\EDSDK\EdsImage.dll" Link="EdsImage.dll">
1517
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
18+
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
19+
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
1620
</None>
1721
</ItemGroup>
1822

build.bat

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ rem Build Canon.API in Release configuration
1313
echo Building Canon.API...
1414
dotnet build Canon.API --configuration Release --no-restore
1515

16-
rem Publish Canon.API for deployment
17-
echo Publishing Canon.API...
18-
dotnet publish Canon.API --configuration Release --output ./publish --no-build --verbosity minimal
16+
rem Publish Canon.API for deployment as standalone executable
17+
echo Publishing Canon.API as standalone executable...
18+
dotnet publish Canon.API/Canon.API.csproj --configuration Release --runtime win-x64 --self-contained true -p:PublishSingleFile=true --output ./publish --verbosity minimal
1919

2020
echo.
2121
echo Build completed successfully!

0 commit comments

Comments
 (0)