diff --git a/Cargo.toml b/Cargo.toml index 677bdfbc..ce0cb262 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -62,7 +62,7 @@ human-sort = "0.2.2" regex = "1.10.5" [target.'cfg(windows)'.dependencies] -windows = { version = "0.58.0", features = ["Win32_Foundation", "Win32_UI_Shell", "Win32_System_Console", "Services_Store", "Foundation", "Foundation_Collections", "Web_Http", "Web_Http_Headers", "Storage_Streams",] } +windows = { version = "0.58.0", features = ["Win32_Foundation", "Win32_UI_Shell", "Win32_System_Console", "Services_Store", "Foundation", "Foundation_Collections", "Web_Http", "Web_Http_Headers", "Storage_Streams", "Management_Deployment"] } [target.'cfg(target_os = "macos")'.dependencies] reqwest = { version = "0.12.3", default-features = false, features = ["blocking", "native-tls", "socks"] } @@ -97,6 +97,7 @@ windowsappinstaller = [] dummy = [] binjuliainstaller = [] binjulialauncher = [] +winpkgidentityext = [] [package.metadata.msix] winstoremsix = { file = "deploy/msix/PackagingLayout.xml", variables = [{name = "FlatBundle", value="false"}, {name = "IdentityPublisher", value = "CN=7FB784C5-4411-4067-914E-A7B06CC00FFC"}] } diff --git a/build.rs b/build.rs index b6225b93..a6c90838 100644 --- a/build.rs +++ b/build.rs @@ -45,6 +45,10 @@ fn main() -> Result<()> { { let mut res = winres::WindowsResource::new(); res.set_icon("src/julia.ico"); + + #[cfg(feature = "winpkgidentityext")] + res.set_manifest_file("deploy/winpkgidentityext/app.manifest"); + res.compile().unwrap(); } diff --git a/deploy/winpkgidentityext/appmanifest/app.manifest b/deploy/winpkgidentityext/appmanifest/app.manifest new file mode 100644 index 00000000..3217a224 --- /dev/null +++ b/deploy/winpkgidentityext/appmanifest/app.manifest @@ -0,0 +1,9 @@ + + + + + diff --git a/deploy/winpkgidentityext/create-msix.ps1 b/deploy/winpkgidentityext/create-msix.ps1 new file mode 100644 index 00000000..4aaf6147 --- /dev/null +++ b/deploy/winpkgidentityext/create-msix.ps1 @@ -0,0 +1,24 @@ +Remove-Item .\juliaup.msix +& 'C:\Program Files (x86)\Windows Kits\10\bin\10.0.22000.0\x64\makeappx.exe' pack /d .\msix\ /p .\juliaup.msix /nv + +$params = @{ + Endpoint = "https://eus.codesigning.azure.net/" + CodeSigningAccountName = "juliahubwincertsaccount" + CertificateProfileName = "JuliaHubWinCert" + FilesFolder = "." + FilesFolderFilter = "msix" + FileDigest = "SHA256" + TimestampRfc3161 = "http://timestamp.acs.microsoft.com" + TimestampDigest = "SHA256" + ExcludeManagedIdentityCredential = $True + ExcludeEnvironmentCredential = $True + ExcludeWorkloadIdentityCredential = $True + ExcludeSharedTokenCacheCredential = $True + ExcludeVisualStudioCredential = $True + ExcludeVisualStudioCodeCredential = $True + ExcludeAzurePowerShellCredential = $True + ExcludeAzureDeveloperCliCredential = $True + ExcludeInteractiveBrowserCredential = $True + } + +Invoke-TrustedSigning @params diff --git a/deploy/winpkgidentityext/juliaup.msix b/deploy/winpkgidentityext/juliaup.msix new file mode 100644 index 00000000..6c117e52 Binary files /dev/null and b/deploy/winpkgidentityext/juliaup.msix differ diff --git a/deploy/winpkgidentityext/msix/appxmanifest.xml b/deploy/winpkgidentityext/msix/appxmanifest.xml new file mode 100644 index 00000000..38a87dfc --- /dev/null +++ b/deploy/winpkgidentityext/msix/appxmanifest.xml @@ -0,0 +1,90 @@ + + + + + + + + Julia Dev + JuliaHub, Inc. + Images\StoreLogo.png + disabled + disabled + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/bin/juliaup.rs b/src/bin/juliaup.rs index 886e041d..b585d3b4 100644 --- a/src/bin/juliaup.rs +++ b/src/bin/juliaup.rs @@ -47,6 +47,44 @@ fn main() -> Result<()> { .write_style("JULIAUP_LOG_STYLE"); env_logger::init_from_env(env); + #[cfg(feature = "winpkgidentityext")] + { + use windows::Management::Deployment::{AddPackageOptions, PackageManager}; + + let package_manager = PackageManager::new().unwrap(); + + let package_manager_options = AddPackageOptions::new().unwrap(); + + let self_location = std::env::current_exe().unwrap(); + let self_location = self_location.parent().unwrap(); + let pkg_loc = self_location.join("juliaup.msix"); + + let external_loc = + windows::Foundation::Uri::CreateUri(&windows::core::HSTRING::from(self_location)) + .unwrap(); + let pkg_loc = + windows::Foundation::Uri::CreateUri(&windows::core::HSTRING::from(pkg_loc.as_os_str())) + .unwrap(); + + package_manager_options + .SetExternalLocationUri(&external_loc) + .unwrap(); + package_manager_options.SetAllowUnsigned(false).unwrap(); + + let depl_result = package_manager + .AddPackageByUriAsync(&pkg_loc, &package_manager_options) + .unwrap() + .get() + .unwrap(); + + if !depl_result.IsRegistered().unwrap() { + println!( + "Failed to register package identity. Error Message ${:?}", + depl_result.ErrorText() + ); + } + } + info!("Parsing command line arguments."); let args = Juliaup::parse();