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

Add a system for testing correlation E2E #2071

Merged
merged 4 commits into from
Apr 11, 2022
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
5 changes: 5 additions & 0 deletions .github/actions/spelling/allow.txt
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ createtables
cref
csproj
CStr
csv
CURSORPOSITON
CUSTOMHEADER
cwctype
Expand Down Expand Up @@ -189,7 +190,9 @@ hfile
HGLOBAL
HIDECANCEL
hinternet
HKCU
HKEY
HKLM
hmac
HMODULE
Homepage
Expand Down Expand Up @@ -448,6 +451,7 @@ screenshots
SCROLLER
SCROLLVIEWER
sdk
sdks
seekg
seinfo
selectany
Expand Down Expand Up @@ -544,6 +548,7 @@ TEXTFORMAT
TEXTINCLUDE
Threadpool
Timeline
tls
todo
tokenizer
tolower
Expand Down
2 changes: 2 additions & 0 deletions .github/actions/spelling/excludes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,6 @@ ignore$
^src/JsonCppLib/
^src/Valijson/
^src/YamlCppLib/
# Because it doesn't handle argument -Words well
^tools/CorrelationTestbed/.*\.ps1$
^\.github/
2 changes: 2 additions & 0 deletions .github/actions/spelling/expect.txt
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,7 @@ vscode
vstest
vy
wcslen
WDAG
webpages
Webserver
website
Expand All @@ -426,6 +427,7 @@ winreg
withstarts
wn
Workflows
wsb
wsl
wsv
wto
Expand Down
1 change: 0 additions & 1 deletion src/AppInstallerCLIPackage/Package.appxmanifest
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
<Dependencies>
<!-- Minimum supported version is 1809 (October 2018 Update, aka RS5) -->
<TargetDeviceFamily Name="Windows.Desktop" MinVersion="10.0.17763.0" MaxVersionTested="10.0.19033.0" />
<PackageDependency Name="Microsoft.VCLibs.140.00.UWPDesktop" MinVersion="14.0.25426.0" Publisher="CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US" />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this removal intentional?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it is being injected by VS anyway. This one was leading to debug needing the release package (as VS left this and injected the debug on as well).

</Dependencies>
<Resources>
<Resource Language="x-generate" />
Expand Down
3 changes: 3 additions & 0 deletions src/Microsoft.Management.Deployment/PackageManager.idl
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,9 @@ namespace Microsoft.Management.Deployment
{
/// Checks if this package version has at least one applicable installer.
Boolean HasApplicableInstaller(InstallOptions options);

/// Gets the publisher string for this package version, if one is available.
String Publisher { get; };
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Add a comment. Seems like most other things here are documented.

florelis marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to do any review for these API changes?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not for these simple ones, no.

florelis marked this conversation as resolved.
Show resolved Hide resolved
}

/// DESIGN NOTE:
Expand Down
4 changes: 4 additions & 0 deletions src/Microsoft.Management.Deployment/PackageVersionInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ namespace winrt::Microsoft::Management::Deployment::implementation
{
return winrt::to_hstring(m_packageVersion->GetProperty(::AppInstaller::Repository::PackageVersionProperty::Name).get());
}
hstring PackageVersionInfo::Publisher()
{
return winrt::to_hstring(m_packageVersion->GetProperty(::AppInstaller::Repository::PackageVersionProperty::Publisher).get());
}
hstring PackageVersionInfo::Version()
{
return winrt::to_hstring(m_packageVersion->GetProperty(::AppInstaller::Repository::PackageVersionProperty::Version).get());
Expand Down
1 change: 1 addition & 0 deletions src/Microsoft.Management.Deployment/PackageVersionInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ namespace winrt::Microsoft::Management::Deployment::implementation
hstring GetMetadata(winrt::Microsoft::Management::Deployment::PackageVersionMetadataField const& metadataField);
hstring Id();
hstring DisplayName();
hstring Publisher();
hstring Version();
hstring Channel();
winrt::Windows::Foundation::Collections::IVectorView<hstring> PackageFamilyNames();
Expand Down
111 changes: 111 additions & 0 deletions tools/CorrelationTestbed/InSandboxScript.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
Param(
[String] $DesktopAppInstallerPath,
[String[]] $DesktopAppInstallerDependencyPath,
[String] $PackageIdentifier,
[String] $SourceName,
[String] $OutputPath,
[Switch] $UseDev
)

function Get-ARPTable {
$registry_paths = @('HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*','HKLM:\Software\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*', 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*', 'HKCU:\Software\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*')
return Get-ItemProperty $registry_paths -ErrorAction SilentlyContinue |
Select-Object DisplayName, DisplayVersion, Publisher, @{N='ProductCode'; E={$_.PSChildName}} |
Where-Object {$null -ne $_.DisplayName }
}

$ProgressPreference = 'SilentlyContinue'

$desktopPath = "C:\Users\WDAGUtilityAccount\Desktop"

$regFilesDirPath = Join-Path $desktopPath "RegFiles"

if (Test-Path $regFilesDirPath)
{
foreach ($regFile in (Get-ChildItem $regFilesDirPath))
{

Write-Host @"
--> Importing reg file $($regFile.FullName)
"@
reg import $($regFile.FullName)
}
}

Write-Host @"
--> Installing WinGet

"@

if ($UseDev)
{
foreach($dependency in $DesktopAppInstallerDependencyPath)
{
Write-Host @"
----> Installing $dependency
"@
Add-AppxPackage -Path $dependency
}

Write-Host @"
----> Enabling dev mode
"@
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock" /t REG_DWORD /f /v "AllowDevelopmentWithoutDevLicense" /d "1"

$devPackageManifestPath = Join-Path $desktopPath "DevPackage\AppxManifest.xml"
Write-Host @"
----> Installing $devPackageManifestPath
"@
Add-AppxPackage -Path $devPackageManifestPath -Register
}
else
{
Add-AppxPackage -Path $DesktopAppInstallerPath -DependencyPath $DesktopAppInstallerDependencyPath
}

$originalARP = Get-ARPTable

Write-Host @"

--> Installing $PackageIdentifier

"@

$installAndCorrelateOutPath = Join-Path $OutputPath "install_and_correlate.json"

$installAndCorrelationExpression = Join-Path $desktopPath "InstallAndCheckCorrelation\InstallAndCheckCorrelation.exe"
$installAndCorrelationExpression = -join($installAndCorrelationExpression, ' -id "', $PackageIdentifier, '" -src "', $SourceName, '" -out "', $installAndCorrelateOutPath, '"')

if ($UseDev)
{
$installAndCorrelationExpression = -join($installAndCorrelationExpression, ' -dev')
}

Invoke-Expression $installAndCorrelationExpression

Write-Host @"

--> Copying logs
"@

if ($UseDev)
{
Copy-Item -Recurse (Join-Path $env:LOCALAPPDATA "Packages\WinGetDevCLI_8wekyb3d8bbwe\LocalState\DiagOutputDir") $OutputPath
}
else
{
Copy-Item -Recurse (Join-Path $env:LOCALAPPDATA "Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\DiagOutputDir") $OutputPath
}


Write-Host @"

--> Comparing ARP Entries
"@

$arpCompared = (Compare-Object (Get-ARPTable) $originalARP -Property DisplayName,DisplayVersion,Publisher,ProductCode)
$arpCompared | Select-Object -Property * -ExcludeProperty SideIndicator | Format-Table

$arpCompared | Select-Object -Property * -ExcludeProperty SideIndicator | Format-Table | Out-File (Join-Path $OutputPath "ARPCompare.txt")

"Done" | Out-File (Join-Path $OutputPath "done.txt")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This won't happen if there is any error during the script, so the main one will just hang waiting for this. I don't know if that is good or bad

Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.31911.196
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "InstallAndCheckCorrelation", "InstallAndCheckCorrelation\InstallAndCheckCorrelation.vcxproj", "{204CD25F-AAEA-4CA1-AB9F-A26747976932}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{204CD25F-AAEA-4CA1-AB9F-A26747976932}.Debug|x64.ActiveCfg = Debug|x64
{204CD25F-AAEA-4CA1-AB9F-A26747976932}.Debug|x64.Build.0 = Debug|x64
{204CD25F-AAEA-4CA1-AB9F-A26747976932}.Debug|x86.ActiveCfg = Debug|Win32
{204CD25F-AAEA-4CA1-AB9F-A26747976932}.Debug|x86.Build.0 = Debug|Win32
{204CD25F-AAEA-4CA1-AB9F-A26747976932}.Release|x64.ActiveCfg = Release|x64
{204CD25F-AAEA-4CA1-AB9F-A26747976932}.Release|x64.Build.0 = Release|x64
{204CD25F-AAEA-4CA1-AB9F-A26747976932}.Release|x86.ActiveCfg = Release|Win32
{204CD25F-AAEA-4CA1-AB9F-A26747976932}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {77ED5C57-8A8C-4D87-9818-ABFB99B8E9D2}
EndGlobalSection
EndGlobal
Loading