Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Experiment with win package identity #962

Merged
merged 8 commits into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
Expand Down Expand Up @@ -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"}] }
Expand Down
4 changes: 4 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
9 changes: 9 additions & 0 deletions deploy/winpkgidentityext/appmanifest/app.manifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
<assemblyIdentity version="1.0.0.0" name="Julialang.Juliaup"/>
<msix xmlns="urn:schemas-microsoft-com:msix.v1"
publisher="CN=&quot;JuliaHub, Inc.&quot;, O=&quot;JuliaHub, Inc.&quot;, L=CAMBRIDGE, S=Massachusetts, C=US"
packageName="Juliaup"
applicationId="Juliaup"
/>
</assembly>
24 changes: 24 additions & 0 deletions deploy/winpkgidentityext/create-msix.ps1
Original file line number Diff line number Diff line change
@@ -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
Binary file added deploy/winpkgidentityext/juliaup.msix
Binary file not shown.
90 changes: 90 additions & 0 deletions deploy/winpkgidentityext/msix/appxmanifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
<?xml version="1.0" encoding="utf-8"?>

<Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest"
xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
xmlns:uap3="http://schemas.microsoft.com/appx/manifest/uap/windows10/3"
xmlns:uap5="http://schemas.microsoft.com/appx/manifest/uap/windows10/5"
xmlns:uap10="http://schemas.microsoft.com/appx/manifest/uap/windows10/10"
xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
xmlns:desktop="http://schemas.microsoft.com/appx/manifest/desktop/windows10"
xmlns:desktop4="http://schemas.microsoft.com/appx/manifest/desktop/windows10/4"
xmlns:desktop6="http://schemas.microsoft.com/appx/manifest/desktop/windows10/6"
xmlns:iot2="http://schemas.microsoft.com/appx/manifest/iot/windows10/2" IgnorableNamespaces="mp uap uap3 uap5 rescap desktop desktop4 desktop6 iot2">

<Identity Name="JuliaHubInc.JuliaDev" Publisher="CN=&quot;JuliaHub, Inc.&quot;, O=&quot;JuliaHub, Inc.&quot;, L=CAMBRIDGE, S=Massachusetts, C=US" Version="1.0.0.0" ProcessorArchitecture="x64"/>

<Properties>
<DisplayName>Julia Dev</DisplayName>
<PublisherDisplayName>JuliaHub, Inc.</PublisherDisplayName>
<Logo>Images\StoreLogo.png</Logo>
<desktop6:FileSystemWriteVirtualization>disabled</desktop6:FileSystemWriteVirtualization>
<desktop6:RegistryWriteVirtualization>disabled</desktop6:RegistryWriteVirtualization>
<uap10:AllowExternalContent>true</uap10:AllowExternalContent>
</Properties>

<Dependencies>
<TargetDeviceFamily Name="Windows.Desktop" MinVersion="10.0.19041.0" MaxVersionTested="10.0.19043.0" />
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.19041.0" MaxVersionTested="10.0.19043.0" />
<PackageDependency Name="Microsoft.VCLibs.140.00.UWPDesktop" MinVersion="14.0.29231.0" Publisher="CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US" />
</Dependencies>

<Resources>
<Resource Language="en-us"/>
</Resources>

<Applications>
<Application Id="Julia" Executable="julialauncher.exe" uap10:TrustLevel="mediumIL" uap10:RuntimeBehavior="win32App">
<uap:VisualElements
DisplayName="Julia"
Description="Julia is a high-level, high-performance, dynamic programming language"
BackgroundColor="transparent"
Square150x150Logo="Images\Square150x150Logo.png"
Square44x44Logo="Images\Square44x44Logo.png">
<uap:DefaultTile
Wide310x150Logo="Images\Wide310x150Logo.png"
ShortName="Julia"
Square71x71Logo="Images\SmallTile.png"
Square310x310Logo="Images\LargeTile.png">
<uap:ShowNameOnTiles>
<uap:ShowOn Tile="square150x150Logo"/>
<uap:ShowOn Tile="wide310x150Logo"/>
<uap:ShowOn Tile="square310x310Logo"/>
</uap:ShowNameOnTiles>
</uap:DefaultTile >
<uap:SplashScreen Image="Images\SplashScreen.png" />
</uap:VisualElements>
<Extensions>
</Extensions>
</Application>
<Application Id="Juliaup" Executable="juliaup.exe" uap10:TrustLevel="mediumIL" uap10:RuntimeBehavior="win32App">
<uap:VisualElements
DisplayName="Juliaup"
Description="Julia version management"
BackgroundColor="transparent"
Square150x150Logo="Images\Square150x150Logo.png"
Square44x44Logo="Images\Square44x44Logo.png"
AppListEntry="none">
<uap:DefaultTile
Wide310x150Logo="Images\Wide310x150Logo.png"
ShortName="Julia"
Square71x71Logo="Images\SmallTile.png"
Square310x310Logo="Images\LargeTile.png">
<uap:ShowNameOnTiles>
<uap:ShowOn Tile="square150x150Logo"/>
<uap:ShowOn Tile="wide310x150Logo"/>
<uap:ShowOn Tile="square310x310Logo"/>
</uap:ShowNameOnTiles>
</uap:DefaultTile >
<uap:SplashScreen Image="Images\SplashScreen.png" />
</uap:VisualElements>
<Extensions>
</Extensions>
</Application>
</Applications>

<Capabilities>
<rescap:Capability Name="runFullTrust" />
<rescap:Capability Name="unvirtualizedResources"/>
</Capabilities>
</Package>
38 changes: 38 additions & 0 deletions src/bin/juliaup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down