├── .ci └── ci_release.yml ├── .config ├── CredScanSuppressions.json └── tsaoptions.json ├── .gitattributes ├── .gitignore ├── .gitmodules ├── .nuget ├── NuGet.Config ├── NuGet.exe ├── NuGet.targets └── packages.config ├── .pipelines └── PackageManagement-Official.yml ├── .travis.yml ├── Changelog.md ├── LICENSE ├── SignConfig .xml ├── SignConfig.xml ├── StrongNameSignConfig.xml ├── Test ├── DSCTests │ ├── OneGetTestHelper.ps1 │ └── tests │ │ ├── OneGetSource.Get.Set.Test.Tests.ps1 │ │ ├── PackageManagement.Get.Tests.ps1 │ │ ├── PackageManagement.Set.Tests.ps1 │ │ ├── PackageManagement.Test.Tests.ps1 │ │ └── PackageManagement.Tests.ps1 ├── Examples │ ├── Sample_Install_Package.ps1 │ └── Sample_Install_Package_Using_NuGet.ps1 ├── ModuleTests │ ├── .gitignore │ ├── scripts │ │ ├── import-certificate.ps1 │ │ ├── install-certificates.ps1 │ │ ├── notes.txt │ │ ├── start-sandbox.ps1 │ │ ├── stop-sandbox.ps1 │ │ ├── test-pester.ps1 │ │ ├── test-sandbox.ps1 │ │ ├── uninstall-certificates.ps1 │ │ └── webserver.ps1 │ ├── tests │ │ ├── find-packageprovider.tests.ps1 │ │ ├── get-package.tests.ps1 │ │ ├── get-packageprovider.tests.ps1 │ │ ├── import-packageprovider.tests.ps1 │ │ ├── install-packageprovider.tests.ps1 │ │ ├── nuget.tests.ps1 │ │ ├── psget.tests.ps1 │ │ ├── test-template.ps1 │ │ ├── utility.psm1 │ │ └── vsts.tests.ps1 │ └── tools │ │ ├── DnsShim.exe │ │ ├── Shim32.dll │ │ ├── Shim64.dll │ │ ├── hosts.txt │ │ └── snremove.exe ├── OneGetTestProvider │ ├── OneGetTestProvider.csproj │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── Resources │ │ ├── Messages.Designer.cs │ │ └── Messages.resx │ ├── Sdk │ │ ├── Constants.cs │ │ ├── ErrorCategory.cs │ │ └── request.cs │ ├── packageprovider.cs │ └── provider.manifest ├── PSL │ ├── win10 │ │ └── PSL.json │ └── win81 │ │ └── PSL.json ├── Packages_100.txt ├── Packages_128.txt ├── TestUtility.psm1 ├── Unit │ └── Providers │ │ ├── Dependencies │ │ ├── BigDependenciesLoop │ │ │ ├── ModuleA.1.0.nupkg │ │ │ ├── ModuleB.1.0.nupkg │ │ │ ├── ModuleC.1.0.nupkg │ │ │ └── ModuleD.1.0.nupkg │ │ └── SimpleDependenciesLoop │ │ │ ├── ModuleWithDependenciesLoop.1.0.nupkg │ │ │ └── RequiredModuleLoop.1.0.nupkg │ │ ├── PSChained1Provider.psm1 │ │ ├── PSOneGetTestProvider │ │ ├── 1.1 │ │ │ ├── OneGetTestProvider.psm1 │ │ │ ├── PSOneGetTestProvider.psd1 │ │ │ └── PSOneGetTestProvider.psm1 │ │ ├── 3.5 │ │ │ ├── OneGetTestProvider.psm1 │ │ │ ├── PSOneGetTestProvider.psd1 │ │ │ └── PSOneGetTestProvider.psm1 │ │ └── 9.9 │ │ │ ├── OneGetTestProvider.psm1 │ │ │ ├── PSOneGetTestProvider.psd1 │ │ │ └── PSOneGetTestProvider.psm1 │ │ ├── Providers.psd1 │ │ ├── TestChainingPackageProvider.psm1 │ │ ├── TestPackageProvider.psm1 │ │ └── TestProviders.psm1 └── run-tests.ps1 ├── UpdatePackage.psm1 ├── assembly-version.cs ├── assets └── OneGetArchitecture.PNG ├── docs ├── README.md └── writepowershellbasedprovider.md ├── global.json ├── nuget.config ├── owners.txt ├── readme.md ├── solution.props ├── src ├── Microsoft.PackageManagement.ArchiverProviders │ ├── CabArchiver.cs │ ├── Compression │ │ ├── ArchiveException.cs │ │ ├── ArchiveFileInfo.cs │ │ ├── ArchiveFileStreamContext.cs │ │ ├── ArchiveInfo.cs │ │ ├── ArchiveProgressEventArgs.cs │ │ ├── ArchiveProgressType.cs │ │ ├── BasicUnpackStreamContext.cs │ │ ├── Cab │ │ │ ├── CabEngine.cs │ │ │ ├── CabException.cs │ │ │ ├── CabFileInfo.cs │ │ │ ├── CabInfo.cs │ │ │ ├── CabPacker.cs │ │ │ ├── CabUnpacker.cs │ │ │ ├── CabWorker.cs │ │ │ ├── HandleManager.cs │ │ │ └── NativeMethods.cs │ │ ├── CargoStream.cs │ │ ├── CompressionEngine.cs │ │ ├── CompressionLevel.cs │ │ ├── DuplicateStream.cs │ │ ├── IPackStreamContext.cs │ │ ├── IUnpackStreamContext.cs │ │ ├── OffsetStream.cs │ │ ├── SafeNativeMethods.cs │ │ └── Zip │ │ │ ├── ConcatStream.cs │ │ │ ├── CrcStream.cs │ │ │ ├── ZipCompressionMethod.cs │ │ │ ├── ZipEngine.cs │ │ │ ├── ZipException.cs │ │ │ ├── ZipFileInfo.cs │ │ │ ├── ZipFormat.cs │ │ │ ├── ZipInfo.cs │ │ │ ├── ZipPacker.cs │ │ │ └── ZipUnpacker.cs │ ├── Microsoft.PackageManagement.ArchiverProviders.csproj │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── ZipArchiver.cs │ ├── provider.manifest │ └── vs-csproj │ │ └── Archivers.csproj ├── Microsoft.PackageManagement.CoreProviders │ ├── Bootstrap │ │ ├── BootstrapProvider.cs │ │ ├── BootstrapRequest.cs │ │ ├── Feed.cs │ │ ├── Package.cs │ │ └── Swid.cs │ ├── Microsoft.PackageManagement.CoreProviders.csproj │ ├── ProgramsProvider.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── WebDownloader.cs │ ├── provider.manifest │ ├── resources │ │ ├── Messages.Designer.cs │ │ └── Messages.resx │ └── vs-csproj │ │ └── CoreProviders.csproj ├── Microsoft.PackageManagement.DscResources │ ├── MSFT_PackageManagement │ │ ├── MSFT_PackageManagement.psm1 │ │ ├── MSFT_PackageManagement.schema.mfl │ │ ├── MSFT_PackageManagement.schema.mof │ │ └── MSFT_PackageManagement.strings.psd1 │ ├── MSFT_PackageManagementSource │ │ ├── MSFT_PackageManagementSource.psm1 │ │ ├── MSFT_PackageManagementSource.schema.mfl │ │ ├── MSFT_PackageManagementSource.schema.mof │ │ └── MSFT_PackageManagementSource.strings.psd1 │ ├── PackageManagementDscUtilities.psm1 │ └── PackageManagementDscUtilities.strings.psd1 ├── Microsoft.PackageManagement.MetaProvider.PowerShell │ ├── Constants.cs │ ├── Dependency.cs │ ├── DynamicOption.cs │ ├── Entity.cs │ ├── Enums.cs │ ├── Feature.cs │ ├── Link.cs │ ├── Microsoft.PackageManagement.MetaProvider.PowerShell.csproj │ ├── PackageSource.cs │ ├── PowerShellExtensions.cs │ ├── PowerShellMetaProvider.cs │ ├── PowerShellPackageProvider.cs │ ├── PowerShellProviderBase.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── Request.cs │ ├── SoftwareIdentity.cs │ ├── Yieldable.cs │ ├── provider.manifest │ ├── resources │ │ ├── Messages.Designer.cs │ │ └── Messages.resx │ └── vs-csproj │ │ └── PowerShell.MetaProvider.csproj ├── Microsoft.PackageManagement.MsiProvider │ ├── Deployment │ │ ├── Resources │ │ │ ├── BitmapResource.cs │ │ │ ├── FixedFileVersionInfo.cs │ │ │ ├── GroupIconInfo.cs │ │ │ ├── GroupIconResource.cs │ │ │ ├── NativeMethods.cs │ │ │ ├── Resource.cs │ │ │ ├── ResourceCollection.cs │ │ │ ├── ResourceType.cs │ │ │ ├── VersionEnums.cs │ │ │ ├── VersionInfo.cs │ │ │ ├── VersionResource.cs │ │ │ └── VersionStringTable.cs │ │ ├── WindowsInstaller.Linq │ │ │ ├── Attributes.cs │ │ │ ├── Entities.cs │ │ │ ├── QDatabase.cs │ │ │ ├── QRecord.cs │ │ │ ├── QTable.cs │ │ │ └── Query.cs │ │ ├── WindowsInstaller.Package │ │ │ ├── InstallPackage.cs │ │ │ ├── InstallPath.cs │ │ │ ├── PatchPackage.cs │ │ │ └── TransformInfo.cs │ │ └── WindowsInstaller │ │ │ ├── ColumnCollection.cs │ │ │ ├── ColumnEnums.cs │ │ │ ├── ColumnInfo.cs │ │ │ ├── ComponentInfo.cs │ │ │ ├── ComponentInstallation.cs │ │ │ ├── CustomActionAttribute.cs │ │ │ ├── CustomActionProxy.cs │ │ │ ├── Database.cs │ │ │ ├── DatabaseQuery.cs │ │ │ ├── DatabaseTransform.cs │ │ │ ├── EmbeddedUIProxy.cs │ │ │ ├── Enums.cs │ │ │ ├── Exceptions.cs │ │ │ ├── ExternalUIHandler.cs │ │ │ ├── FeatureInfo.cs │ │ │ ├── FeatureInstallation.cs │ │ │ ├── Handle.cs │ │ │ ├── IEmbeddedUI.cs │ │ │ ├── InstallCost.cs │ │ │ ├── Installation.cs │ │ │ ├── InstallationPart.cs │ │ │ ├── Installer.cs │ │ │ ├── InstallerAdvertise.cs │ │ │ ├── InstallerUtils.cs │ │ │ ├── MediaDisk.cs │ │ │ ├── NativeMethods.cs │ │ │ ├── PatchInstallation.cs │ │ │ ├── ProductInstallation.cs │ │ │ ├── Record.cs │ │ │ ├── RecordStream.cs │ │ │ ├── RemotableNativeMethods.cs │ │ │ ├── Session.cs │ │ │ ├── ShortcutTarget.cs │ │ │ ├── SourceList.cs │ │ │ ├── SourceMediaList.cs │ │ │ ├── SummaryInfo.cs │ │ │ ├── TableCollection.cs │ │ │ ├── TableInfo.cs │ │ │ ├── Transaction.cs │ │ │ ├── ValidationErrorInfo.cs │ │ │ ├── View.cs │ │ │ └── customactiondata.cs │ ├── Microsoft.PackageManagement.MsiProvider.csproj │ ├── MsiProvider.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── provider.manifest │ ├── resources │ │ ├── Messages.Designer.cs │ │ └── Messages.resx │ └── vs-csproj │ │ └── MsiProvider.csproj ├── Microsoft.PackageManagement.MsuProvider │ ├── Microsoft.PackageManagement.MsuProvider.csproj │ ├── MsuProvider.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── provider.manifest │ ├── resources │ │ ├── Messages.Designer.cs │ │ └── Messages.resx │ └── vs-csproj │ │ └── MsuProvider.csproj ├── Microsoft.PackageManagement │ ├── Api │ │ ├── ICoreApi.cs │ │ ├── IHostAPI.cs │ │ ├── IProviderServices.cs │ │ ├── IRequest.cs │ │ └── IResponseApi.cs │ ├── Constants.cs │ ├── ErrorCategory.cs │ ├── IPackageManagementService.cs │ ├── Implementation │ │ ├── ActionRequestObject.cs │ │ ├── Archiver.cs │ │ ├── DefaultPackageProvider.cs │ │ ├── DictionaryRequestObject.cs │ │ ├── Downloader.cs │ │ ├── DynamicOptionRequestObject.cs │ │ ├── EnumerableRequestObject.cs │ │ ├── Extensions.cs │ │ ├── FuncRequestObject.cs │ │ ├── PackageDetailsRequestObject.cs │ │ ├── PackageManagementService.cs │ │ ├── PackageProvider.cs │ │ ├── PackageSourceRequestObject.cs │ │ ├── ProviderBase.cs │ │ ├── ProviderServicesImpl.cs │ │ ├── Request.cs │ │ ├── RequestObject.cs │ │ └── SoftwareIdentityRequestObject.cs │ ├── Microsoft.PackageManagement.csproj │ ├── PackageManager.cs │ ├── Packaging │ │ ├── AttributeIndexer.cs │ │ ├── BaseElement.cs │ │ ├── Directory.cs │ │ ├── DynamicOption.cs │ │ ├── Entity.cs │ │ ├── Evidence.cs │ │ ├── File.cs │ │ ├── FilesystemItem.cs │ │ ├── Iso19770_2.cs │ │ ├── Link.cs │ │ ├── MediaQuery.cs │ │ ├── Meta.cs │ │ ├── MetadataIndexer.cs │ │ ├── OptionCategory.cs │ │ ├── OptionType.cs │ │ ├── PackageSource.cs │ │ ├── Payload.cs │ │ ├── Process.cs │ │ ├── Resource.cs │ │ ├── ResourceCollection.cs │ │ ├── SoftwareIdentity.cs │ │ ├── SoftwareIdentityNameVersionComparer.cs │ │ ├── SoftwareIdentityVersionComparer.cs │ │ ├── SoftwareMetadata.cs │ │ └── Swidtag.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── Utility │ │ ├── Async │ │ │ ├── AsyncAction.cs │ │ │ ├── AsyncActionExtensions.cs │ │ │ ├── EmptyAsyncEnumerable.cs │ │ │ ├── IAsyncAction.cs │ │ │ ├── IAsyncEnumerable.cs │ │ │ └── IAsyncValue.cs │ │ ├── Collections │ │ │ ├── BlockingCollection.cs │ │ │ ├── CancellableEnumerator.cs │ │ │ ├── EnumerableExtensions.cs │ │ │ ├── FilenameEqualityComparer.cs │ │ │ ├── ICancellableEnumerator.cs │ │ │ ├── List.cs │ │ │ ├── MutableEnumerable.cs │ │ │ ├── OrderedDictionary.cs │ │ │ ├── PathEqualityComparer.cs │ │ │ └── ReEnumerable.cs │ │ ├── Extensions │ │ │ ├── CollectionExtensions.cs │ │ │ ├── DelegateExtensions.cs │ │ │ ├── DictionaryExtensions.cs │ │ │ ├── EqualityComparer.cs │ │ │ ├── ExceptionExtensions.cs │ │ │ ├── FilesystemExtensions.cs │ │ │ ├── HashtableExtensions.cs │ │ │ ├── Singleon.cs │ │ │ ├── StringExtensions.cs │ │ │ ├── TaskExtensions.cs │ │ │ ├── ThreadPerTaskScheduler.cs │ │ │ └── Types.cs │ │ ├── Platform │ │ │ ├── AdminPrivilege.cs │ │ │ ├── AsyncProcess.cs │ │ │ ├── NativeMethods.cs │ │ │ ├── OSInformation.cs │ │ │ ├── PlatformUtility.cs │ │ │ ├── WinTrustData.cs │ │ │ └── WinTrustFileInfo.cs │ │ ├── Plugin │ │ │ ├── AssignableTypeComparer.cs │ │ │ ├── DynamicInterface.cs │ │ │ ├── DynamicInterfaceExtensions.cs │ │ │ ├── DynamicType.cs │ │ │ ├── DynamicTypeExtensions.cs │ │ │ ├── FluentIlExtensions.cs │ │ │ ├── RequiredAttribute.cs │ │ │ └── WrappedDelegate.cs │ │ └── Versions │ │ │ ├── FourPartVersion.cs │ │ │ └── TwoPartVersion.cs │ ├── providers │ │ ├── IArchiver.cs │ │ ├── IDownloader.cs │ │ ├── IMetaProvider.cs │ │ ├── IPackageProvider.cs │ │ ├── IProvider.cs │ │ └── inbox │ │ │ └── Common │ │ │ ├── Extensions │ │ │ ├── CollectionExtensions.cs │ │ │ ├── EnumerableExtensions.cs │ │ │ ├── EqualityComparer.cs │ │ │ ├── Extensions.cs │ │ │ ├── FilesystemExtensions.cs │ │ │ ├── MutableEnumerable.cs │ │ │ └── ReEnumerable.cs │ │ │ ├── Utility │ │ │ ├── FileUtility.cs │ │ │ ├── PathUtility.cs │ │ │ └── XmlUtility.cs │ │ │ └── Version │ │ │ ├── DependencyVersion.cs │ │ │ ├── SemanticVersion.cs │ │ │ └── SemanticVersionTypeConverter.cs │ ├── resources │ │ ├── Messages.Designer.cs │ │ └── Messages.resx │ └── vs-csproj │ │ └── PackageManagement.csproj ├── Microsoft.PowerShell.PackageManagement │ ├── Cmdlets │ │ ├── AsyncCmdlet.cs │ │ ├── CmdletBase.cs │ │ ├── CmdletWithProvider.cs │ │ ├── CmdletWithSearch.cs │ │ ├── CmdletWithSearchAndSource.cs │ │ ├── CmdletWithSource.cs │ │ ├── FindPackage.cs │ │ ├── FindPackageProvider.cs │ │ ├── GetPackage.cs │ │ ├── GetPackageProvider.cs │ │ ├── GetPackageSource.cs │ │ ├── ImportPackageProvider.cs │ │ ├── InstallPackage.cs │ │ ├── InstallPackageProvider.cs │ │ ├── Properties │ │ │ └── AssemblyInfo.cs │ │ ├── RegisterPackageSource.cs │ │ ├── SavePackage.cs │ │ ├── SetPackageSource.cs │ │ ├── UninstallPackage.cs │ │ └── UnregisterPackageSource.cs │ ├── Constants.cs │ ├── Microsoft.PowerShell.PackageManagement.csproj │ ├── PackageManagement.Resources.psd1 │ ├── PackageManagement.format.ps1xml │ ├── PackageManagement.psd1 │ ├── PackageManagement.psm1 │ ├── PackageProviderFunctions.psm1 │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── Utility │ │ ├── CustomRuntimeDefinedParameter.cs │ │ ├── ErrorMessage.cs │ │ ├── HostApiExtensions.cs │ │ ├── ProgressTracker.cs │ │ ├── ValidateListAttribute.cs │ │ └── WebProxy.cs │ ├── resources │ │ ├── Messages.Designer.cs │ │ └── Messages.resx │ └── vs-csproj │ │ └── PowerShell.Module.csproj ├── New-StronglyTypedCsFileForResx.ps1 ├── PackageManagement.sln ├── bootstrap.ps1 ├── build.ps1 └── signing │ └── 35MSSharedLib1024.snk ├── test.ps1 └── tools ├── download.sh ├── mt.exe └── travis.sh /.ci/ci_release.yml: -------------------------------------------------------------------------------- 1 | name: $(BuildDefinitionName)-$(date:yyMM).$(date:dd)$(rev:rrr) 2 | trigger: none 3 | pr: none 4 | 5 | variables: 6 | - group: ESRP 7 | 8 | resources: 9 | repositories: 10 | - repository: ComplianceRepo 11 | type: github 12 | endpoint: ComplianceGHRepo 13 | name: PowerShell/compliance 14 | 15 | stages: 16 | - stage: Release 17 | displayName: Publish Package to PSGallery 18 | condition: and(and(succeeded(), eq(variables['Build.Reason'], 'Manual')), eq(variables['Publish'], 'True')) 19 | jobs: 20 | - template: release.yml 21 | -------------------------------------------------------------------------------- /.config/CredScanSuppressions.json: -------------------------------------------------------------------------------- 1 | { 2 | "tool": "Credential Scanner", 3 | "suppressions": [ 4 | { 5 | "file": "/Test/ModuleTests/tests/install-packageprovider.tests.ps1", 6 | "_justification": "Fake password" 7 | }, 8 | { 9 | "file": "Test/ModuleTests/tests/nuget.tests.ps1", 10 | "_justification": "Auto generated fake key" 11 | }, 12 | { 13 | "file": "Test/ModuleTests/scripts/notes.txt", 14 | "_justification": "Fake password" 15 | } 16 | ] 17 | } 18 | -------------------------------------------------------------------------------- /.config/tsaoptions.json: -------------------------------------------------------------------------------- 1 | { 2 | "instanceUrl": "https://msazure.visualstudio.com", 3 | "projectName": "One", 4 | "areaPath": "One\\MGMT\\Compute\\Powershell\\Powershell\\PowerShell Core", 5 | "notificationAliases": [ 6 | "adityap@microsoft.com", 7 | "americks@microsoft.com", 8 | "annavied@microsoft.com" 9 | ] 10 | } 11 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | *.doc diff=astextplain 2 | *.DOC diff=astextplain 3 | *.docx diff=astextplain 4 | *.DOCX diff=astextplain 5 | *.dot diff=astextplain 6 | *.DOT diff=astextplain 7 | *.pdf diff=astextplain 8 | *.PDF diff=astextplain 9 | *.rtf diff=astextplain 10 | *.RTF diff=astextplain 11 | 12 | *.jpg binary 13 | *.png binary 14 | *.gif binary 15 | 16 | *.cs -text diff=csharp 17 | *.vb -text 18 | *.c -text 19 | *.cpp -text 20 | *.cxx -text 21 | *.h -text 22 | *.hxx -text 23 | *.py -text 24 | *.rb -text 25 | *.java -text 26 | *.html -text 27 | *.htm -text 28 | *.css -text 29 | *.scss -text 30 | *.sass -text 31 | *.less -text 32 | *.js -text 33 | *.lisp -text 34 | *.clj -text 35 | *.sql -text 36 | *.php -text 37 | *.lua -text 38 | *.m -text 39 | *.asm -text 40 | *.erl -text 41 | *.fs -text 42 | *.fsx -text 43 | *.hs -text 44 | *.tt -text 45 | 46 | *.csproj -text merge=union 47 | *.vbproj -text merge=union 48 | *.fsproj -text merge=union 49 | *.dbproj -text merge=union 50 | *.sln -text eol=crlf merge=union 51 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | *buildchk* 5 | 6 | # User-specific files 7 | *.suo 8 | *.wixpdb 9 | *.msi 10 | *.user 11 | *.sln.docstates 12 | Messages.Designer.cs 13 | 14 | src/Microsoft.PackageManagement.CoreProviders/resources/Microsoft.PackageManagement.Providers.Resources.Messages.resx 15 | src/Microsoft.PackageManagement.MetaProvider.PowerShell/resources/Microsoft.PackageManagement.MetaProvider.PowerShell.Internal.Resources.Messages.resx 16 | src/Microsoft.PackageManagement.MsiProvider/resources/Microsoft.PackageManagement.Msi.Internal.Resources.Messages.resx 17 | src/Microsoft.PackageManagement.MsuProvider/resources/Microsoft.PackageManagement.Msu.Internal.Resources.Messages.resx 18 | src/Microsoft.PackageManagement/resources/Microsoft.PackageManagement.Internal.Resources.Messages.resx 19 | src/Microsoft.PowerShell.PackageManagement/resources/Microsoft.PowerShell.PackageManagement.Resources.Messages.resx 20 | 21 | # Build results 22 | 23 | [Dd]ebug/ 24 | [Rr]elease/ 25 | x64/ 26 | build/ 27 | [Bb]in/ 28 | [Oo]bj/ 29 | [Oo]ut/ 30 | [Gg]en/ 31 | dotnet-install.ps1 32 | 33 | # MSTest test Results 34 | [Tt]est[Rr]esult*/ 35 | [Bb]uild[Ll]og.* 36 | 37 | *_i.c 38 | *_p.c 39 | *.ilk 40 | *.meta 41 | *.obj 42 | *.pch 43 | *.pdb 44 | *.pgc 45 | *.pgd 46 | *.rsp 47 | *.sbr 48 | *.tlb 49 | *.tli 50 | *.tlh 51 | *.tmp 52 | *.tmp_proj 53 | *.log 54 | *.vspscc 55 | *.vssscc 56 | .builds 57 | *.pidb 58 | *.log 59 | *.scc 60 | *.ffs_db 61 | 62 | 63 | # Visual C++ cache files 64 | ipch/ 65 | *.aps 66 | *.ncb 67 | *.opensdf 68 | *.sdf 69 | *.opensdf 70 | *.nupkg 71 | output 72 | intermediate 73 | obj 74 | 75 | _Resharper* 76 | *.ReSharper 77 | ipch 78 | *.InstallLog 79 | packages 80 | *.wixobj 81 | 82 | *.lock.json 83 | 84 | *.suo 85 | *.wixpdb 86 | *.msi 87 | *.user 88 | *.sdf 89 | *.opensdf 90 | *.nupkg 91 | output/ 92 | intermediate/ 93 | _UpgradeReport_Files/ 94 | obj/ 95 | bin/ 96 | _Resharper* 97 | *.ReSharper 98 | ipch 99 | *.InstallLog 100 | packages 101 | Scratch/snippets.txt 102 | Scratch/test2.props 103 | /Powershell.Provider/test.ps1 104 | /psexamples 105 | /_unused_code.cs 106 | /mar25.txt 107 | .syncignore 108 | *.bak 109 | /AbstractDesign 110 | build-ps.cmd 111 | streams.exe 112 | /attic/ 113 | policheck* 114 | *.orig 115 | OneGet.orig.sln 116 | *pingme* 117 | .nuget 118 | UpgradeLog.htm 119 | manifests/ 120 | xunit-test-results.xml 121 | signed/ 122 | .vs/ 123 | log.txt -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "src/Microsoft.PackageManagement.NuGetProvider"] 2 | path = src/Microsoft.PackageManagement.NuGetProvider 3 | url = https://github.com/OneGet/NuGetProvider.git 4 | -------------------------------------------------------------------------------- /.nuget/NuGet.Config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.nuget/NuGet.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OneGet/oneget/d25ee92d7b3195c0bcf6f0a6162bd928418f20f6/.nuget/NuGet.exe -------------------------------------------------------------------------------- /.nuget/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | 2 | language: cpp 3 | 4 | git: 5 | depth: 1000 6 | 7 | os: 8 | - linux 9 | - osx 10 | sudo: required 11 | dist: trusty 12 | osx_image: xcode9.4 13 | env: 14 | - api=v2 15 | - api=v3 16 | 17 | matrix: 18 | allow_failures: 19 | - os: osx 20 | fast_finish: true 21 | 22 | install: 23 | - export PATH=~/.dotnet:$PATH 24 | - pushd tools 25 | - chmod +x download.sh 26 | - chmod +x travis.sh 27 | - ./download.sh 28 | - popd 29 | 30 | script: 31 | - ./tools/travis.sh $api 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /Changelog.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | ## 1.4.8.1 3 | * Update PackageManagement's strong name signing 4 | 5 | ## 1.4.8 6 | * Add NuGet as a source when generating nuget.config file for user in the NuGet Provider 7 | 8 | ## 1.4.7 9 | * Update security protocol to use TLS 1.2 10 | * Remove catalog file 11 | 12 | ## 1.4.6 13 | * Update `HelpInfoUri` to point to the latest content 14 | 15 | ## 1.4.5 16 | * Bug fix for deadlock when getting parameters in an event 17 | 18 | ## 1.4.4 19 | * Bug fix when installing modules from private feeds 20 | 21 | ## 1.4.3 22 | * Another bug fix when registering repositories with PowerShellGet 23 | 24 | ## 1.4.2 25 | * Bug fix for passing credentials from PowerShellGet when registering repositories 26 | 27 | ## 1.4.1 28 | * Bug fix for using credential provider installed in Visual Studio 29 | 30 | ## 1.4 31 | * Allow credential persistance for registering private repositories and finding or installing packages from those repositories 32 | 33 | ## 1.3.2 34 | * Enable bootstrap on PSCore 35 | * Bug fix to run on .NET Core 3.0 36 | 37 | ## 1.3.1 38 | 39 | Targets net452 and netstandard2.0 instead of net451, netcoreapp2.0, and netstandard1.6 40 | 41 | ## Previous releases are not included in this Changelog -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) Microsoft Corporation 2 | All rights reserved. 3 | 4 | MIT License 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the Software), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in all 14 | copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | SOFTWARE. 23 | -------------------------------------------------------------------------------- /Test/DSCTests/tests/PackageManagement.Tests.ps1: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) Microsoft Corporation. All rights reserved. 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # http://www.apache.org/licenses/LICENSE-2.0 7 | # 8 | # Unless required by applicable law or agreed to in writing, software 9 | # distributed under the License is distributed on an "AS IS" BASIS, 10 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | # See the License for the specific language governing permissions and 12 | # limitations under the License. 13 | # 14 | # ------------------ PackageManagement Test ----------------------------------- 15 | 16 | $InternalGallery = "https://www.poshtestgallery.com/api/v2/" 17 | $InternalSource = 'OneGetTestSource' 18 | 19 | 20 | Describe "PackageManagement Acceptance Test" -Tags "Feature" { 21 | 22 | BeforeAll{ 23 | Register-PackageSource -Name Nugettest -provider NuGet -Location https://www.nuget.org/api/v2 -force 24 | Register-PackageSource -Name $InternalSource -Location $InternalGallery -ProviderName 'PowerShellGet' -Trusted -ErrorAction SilentlyContinue 25 | 26 | } 27 | It "get-packageprovider" { 28 | 29 | $gpp = Get-PackageProvider 30 | 31 | $gpp | ?{ $_.name -eq "NuGet" } | should not BeNullOrEmpty 32 | 33 | $gpp | ?{ $_.name -eq "PowerShellGet" } | should not BeNullOrEmpty 34 | } 35 | 36 | It "find-packageprovider PowerShellGet" { 37 | $fpp = (Find-PackageProvider -Name "PowerShellGet" -force).name 38 | $fpp -contains "PowerShellGet" | should be $true 39 | } 40 | 41 | It "install-packageprovider, Expect succeed" { 42 | $ipp = (install-PackageProvider -name gistprovider -force -source $InternalSource -Scope CurrentUser).name 43 | $ipp -contains "gistprovider" | should be $true 44 | } 45 | 46 | it "Find-package" { 47 | $f = Find-Package -ProviderName NuGet -Name jquery -source Nugettest 48 | $f.Name -contains "jquery" | should be $true 49 | } 50 | 51 | it "Install-package" { 52 | $i = install-Package -ProviderName NuGet -Name jquery -force -source Nugettest -Scope CurrentUser 53 | $i.Name -contains "jquery" | should be $true 54 | } 55 | 56 | it "Get-package" { 57 | $g = Get-Package -ProviderName NuGet -Name jquery 58 | $g.Name -contains "jquery" | should be $true 59 | } 60 | 61 | it "save-package" { 62 | $s = save-Package -ProviderName NuGet -Name jquery -path $TestDrive -force -source Nugettest 63 | $s.Name -contains "jquery" | should be $true 64 | } 65 | 66 | it "uninstall-package" { 67 | $u = uninstall-Package -ProviderName NuGet -Name jquery 68 | $u.Name -contains "jquery" | should be $true 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /Test/Examples/Sample_Install_Package.ps1: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) Microsoft Corporation. 3 | # 4 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 5 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 6 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 7 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 8 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 9 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 10 | # THE SOFTWARE. 11 | # 12 | 13 | # This sample configuration does the following 14 | # 1. Registers PowerShellGallery if it is not already 15 | # 2. Downloads GistProvider OneGet provider using Install-Package 16 | # 3. Downloads a Gist from source DFinke using Gist Provider 17 | configuration Sample_Install_Package 18 | { 19 | param 20 | ( 21 | #Target nodes to apply the configuration 22 | [string[]]$NodeName = 'localhost' 23 | ) 24 | 25 | 26 | Import-DscResource -Module PackageManagement -ModuleVersion 1.4.8.1 27 | 28 | Node $NodeName 29 | { 30 | #register package source 31 | PackageManagementSource PSGallery 32 | { 33 | 34 | Ensure = "Present" 35 | Name = "psgallery" 36 | ProviderName= "PowerShellGet" 37 | SourceLocation = "https://www.powershellgallery.com/api/v2/" 38 | InstallationPolicy ="Trusted" 39 | } 40 | 41 | #Install a package from the Powershell gallery 42 | PackageManagement GistProvider 43 | { 44 | Ensure = "present" 45 | Name = "gistprovider" 46 | Source = "PSGallery" 47 | DependsOn = "[PackageManagementSource]PSGallery" 48 | } 49 | 50 | PackageManagement PowerShellTeamOSSUpdateInfo 51 | { 52 | Ensure = "present" 53 | Name = "Get-PSTOss.ps1" 54 | ProviderName = "Gist" 55 | Source = "dfinke" 56 | DependsOn = "[PackageManagement]GistProvider" 57 | } 58 | } 59 | } 60 | 61 | 62 | #Compile it 63 | Sample_Install_Package 64 | 65 | #Run it 66 | Start-DscConfiguration -path .\Sample_Install_Package -wait -Verbose -force 67 | -------------------------------------------------------------------------------- /Test/Examples/Sample_Install_Package_Using_NuGet.ps1: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) Microsoft Corporation. 3 | # 4 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 5 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 6 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 7 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 8 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 9 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 10 | # THE SOFTWARE. 11 | # 12 | 13 | # DSC configuration example for generice PackageManagement DSC resource 14 | # which uses NuGet Provider 15 | 16 | configuration Sample_Install_Package_Using_NuGet 17 | { 18 | param 19 | ( 20 | #Target nodes to apply the configuration 21 | [string[]]$NodeName = 'localhost', 22 | 23 | #Name of the package to be installed 24 | [Parameter(Mandatory)] 25 | [string]$Name, 26 | 27 | #Destination path for the package 28 | [Parameter(Mandatory)] 29 | [string]$DestinationPath, 30 | 31 | #Version of the package to be installed 32 | [string]$RequiredVersion, 33 | 34 | #Source location where the package download from 35 | [string]$Source, 36 | 37 | #Whether the source is Trusted or Untrusted 38 | [string]$InstallationPolicy 39 | ) 40 | 41 | Import-DscResource -Module PackageManagement -ModuleVersion 1.4.7 42 | 43 | Node $NodeName 44 | { 45 | 46 | #register package source 47 | PackageManagementSource SourceRepository 48 | { 49 | 50 | Ensure = "Present" 51 | Name = "MyNuget" 52 | ProviderName= "Nuget" 53 | SourceLocation = "$env:NUGET_API_URL" 54 | InstallationPolicy ="Trusted" 55 | } 56 | 57 | #Install a package from Nuget repository 58 | PackageManagement NugetPackage 59 | { 60 | Ensure = "Present" 61 | Name = $Name 62 | AdditionalParameters = @{"Destination" = $DestinationPath} 63 | RequiredVersion = "2.0.1" 64 | DependsOn = "[PackageManagementSource]SourceRepository" 65 | } 66 | } 67 | } 68 | 69 | 70 | #Compile it 71 | Sample_Install_Package_Using_NuGet -Name "JQuery" -DestinationPath "$env:HomeDrive\test\test" 72 | 73 | #Run it 74 | Start-DscConfiguration -path .\Sample_Install_Package_Using_NuGet -wait -Verbose -force 75 | -------------------------------------------------------------------------------- /Test/ModuleTests/.gitignore: -------------------------------------------------------------------------------- 1 | # ignore stuff 2 | 3 | PackageManagement.Results.XML 4 | buildchk* 5 | /websites/ -------------------------------------------------------------------------------- /Test/ModuleTests/scripts/start-sandbox.ps1: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) Microsoft Corporation. All rights reserved. 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # http://www.apache.org/licenses/LICENSE-2.0 7 | # 8 | # Unless required by applicable law or agreed to in writing, software 9 | # distributed under the License is distributed on an "AS IS" BASIS, 10 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | # See the License for the specific language governing permissions and 12 | # limitations under the License. 13 | # 14 | 15 | 16 | $origdir = (pwd) 17 | 18 | cd $PSScriptRoot 19 | 20 | # where stuff is 21 | $root = resolve-path "$PSScriptRoot\.." 22 | 23 | # check for installed certificates first. 24 | if( (dir "Cert:\LocalMachine\my\" | Where-Object Subject -eq "CN=pmtestcert" ).Length -eq 0 ) { 25 | write-warning "pmtestcert does not appear to be installed" 26 | cd $origdir 27 | return; 28 | } 29 | 30 | # Make sure the sandbox can run 31 | if (get-command remove-iissite -ea silentlycontinue) { 32 | 33 | if (get-iissite -Name "Default Web Site" ) { 34 | remove-iissite -Name "Default Web Site" -Confirm:$false 35 | 36 | if (get-iissite -Name "Default Web Site" ) { 37 | throw "UNABLE TO REMOVE DEFAULT WEBSITE" 38 | } 39 | } 40 | } 41 | 42 | if( (.\test-sandbox.ps1) ) { 43 | write-warning "Sandbox is already running" 44 | cd $origdir 45 | return; 46 | } 47 | 48 | Write-Host Starting sandbox webserver... 49 | 50 | #run this elevated 51 | If (-Not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) { 52 | $CommandLine = $MyInvocation.Line.Replace($MyInvocation.InvocationName, $MyInvocation.MyCommand.Definition) 53 | Start-Process -FilePath PowerShell.exe -Verb Runas -WorkingDirectory (pwd) -ArgumentList "$CommandLine" 54 | cd $origdir 55 | return 56 | } 57 | 58 | # just start the sandbox server then. 59 | start-process powershell .\webserver.ps1 60 | -------------------------------------------------------------------------------- /Test/ModuleTests/scripts/stop-sandbox.ps1: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) Microsoft Corporation. All rights reserved. 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # http://www.apache.org/licenses/LICENSE-2.0 7 | # 8 | # Unless required by applicable law or agreed to in writing, software 9 | # distributed under the License is distributed on an "AS IS" BASIS, 10 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | # See the License for the specific language governing permissions and 12 | # limitations under the License. 13 | # 14 | 15 | $origdir = (pwd) 16 | 17 | cd $PSScriptRoot 18 | 19 | # where stuff is 20 | $root = resolve-path "$PSScriptRoot\.." 21 | 22 | if( -not (.\test-sandbox.ps1) ) { 23 | write-warning "Sandbox is not running" 24 | cd $origdir 25 | return; 26 | } 27 | 28 | try { 29 | Write-Host Shutting down sandbox webserver. 30 | $null = wget -usebasicparsing http://localhost/quit 31 | } catch { 32 | 33 | } 34 | 35 | cd $origdir 36 | return; 37 | -------------------------------------------------------------------------------- /Test/ModuleTests/scripts/test-pester.ps1: -------------------------------------------------------------------------------- 1 | $origdir = (pwd) 2 | 3 | try { 4 | cd $PSScriptRoot 5 | 6 | if( test-path $PSScriptRoot\..\Pester\Vendor\packages ) { 7 | return $true 8 | } 9 | 10 | } finally { 11 | cd $origdir 12 | } 13 | 14 | return $false -------------------------------------------------------------------------------- /Test/ModuleTests/scripts/test-sandbox.ps1: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) Microsoft Corporation. All rights reserved. 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # http://www.apache.org/licenses/LICENSE-2.0 7 | # 8 | # Unless required by applicable law or agreed to in writing, software 9 | # distributed under the License is distributed on an "AS IS" BASIS, 10 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | # See the License for the specific language governing permissions and 12 | # limitations under the License. 13 | # 14 | 15 | $origdir = (pwd) 16 | 17 | cd $PSScriptRoot 18 | 19 | # where stuff is 20 | $root = resolve-path "$PSScriptRoot\.." 21 | 22 | try { 23 | # quick check to see if port 80 is being listed to at all. 24 | if(-not (((netstat -o -n -a ) -match "0.0.0.0:80").length -gt 0 ) ){ 25 | cd $origdir 26 | return $false 27 | } 28 | 29 | # see if it's the sandbox server listing. 30 | $r = wget -usebasicparsing http://localhost/about-sandbox 31 | 32 | } catch { 33 | cd $origdir 34 | return $false 35 | } 36 | 37 | cd $origdir 38 | return $true 39 | -------------------------------------------------------------------------------- /Test/ModuleTests/scripts/uninstall-certificates.ps1: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) Microsoft Corporation. All rights reserved. 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # http://www.apache.org/licenses/LICENSE-2.0 7 | # 8 | # Unless required by applicable law or agreed to in writing, software 9 | # distributed under the License is distributed on an "AS IS" BASIS, 10 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | # See the License for the specific language governing permissions and 12 | # limitations under the License. 13 | # 14 | 15 | $origdir = (pwd) 16 | 17 | cd $PSScriptRoot 18 | 19 | # where stuff is 20 | $root = resolve-path "$PSScriptRoot\.." 21 | 22 | # check for installed certificates first. 23 | if( (dir "Cert:\LocalMachine\my\" | Where-Object Subject -eq "CN=pmtestcert" ).Length -eq 0 ) { 24 | write-warning "pmtestcert does not appear to be installed" 25 | cd $origdir 26 | return; 27 | } 28 | 29 | #run this elevated 30 | If (-Not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) { 31 | $CommandLine = $MyInvocation.Line.Replace($MyInvocation.InvocationName, $MyInvocation.MyCommand.Definition) 32 | Start-Process -FilePath PowerShell.exe -Verb Runas -Wait -WorkingDirectory (pwd) -ArgumentList "$CommandLine" 33 | cd $origdir 34 | return 35 | } 36 | 37 | # aribtrary app id 38 | $appid = '{df8c8073-5a4b-4810-b469-5975a9c95230}' 39 | 40 | # which servers to fake out 41 | $Servers = @( "pmtestcert","www.google.com","google.com","go.microsoft.com","nuget.org","www.nuget.org","microsoft.com","localhost","chocolatey.org","www.chocolatey.org","oneget.org","www.oneget.org","*.com","*.org","*.net","127.0.0.1","*" ) 42 | 43 | 44 | #unbind the SSL certificates 45 | $null = ($Servers | foreach { $v ="$_"+":443" ; netsh http delete sslcert hostnameport=$v }) 46 | $null = (netsh http delete sslcert ipport=127.0.0.1:443) 47 | 48 | # remove the certs from the store. 49 | dir "Cert:\LocalMachine\my\" | Where-Object Subject -eq "CN=pmtestcert" | erase 50 | dir "Cert:\LocalMachine\root\" | Where-Object Subject -eq "CN=pmtestcert" | erase 51 | 52 | Write-Host "Done removing test certificates" 53 | 54 | cd $origdir 55 | return 56 | -------------------------------------------------------------------------------- /Test/ModuleTests/tests/test-template.ps1: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) Microsoft Corporation. All rights reserved. 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # http://www.apache.org/licenses/LICENSE-2.0 7 | # 8 | # Unless required by applicable law or agreed to in writing, software 9 | # distributed under the License is distributed on an "AS IS" BASIS, 10 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | # See the License for the specific language governing permissions and 12 | # limitations under the License. 13 | # 14 | # ------------------ PackageManagement Test ---------------------------------------------- 15 | ipmo "$PSScriptRoot\utility.psm1" 16 | 17 | # ------------------------------------------------------------------------------ 18 | # Actual Tests: 19 | 20 | 21 | Describe "test name goes here" -Tags @('BVT', 'DRT'){ 22 | # make sure that packagemanagement is loaded 23 | import-packagemanagement 24 | 25 | It "does something useful" { 26 | $true | should be $true 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Test/ModuleTests/tests/utility.psm1: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) Microsoft Corporation. All rights reserved. 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # http://www.apache.org/licenses/LICENSE-2.0 7 | # 8 | # Unless required by applicable law or agreed to in writing, software 9 | # distributed under the License is distributed on an "AS IS" BASIS, 10 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | # See the License for the specific language governing permissions and 12 | # limitations under the License. 13 | # 14 | 15 | <# 16 | .SYNOPSIS 17 | Removes all installed PackageManagement providers from: 18 | $Env:ProgramFiles/PackageManagement/ProviderAssemblies 19 | $Env:LocalAppData/PackageManagement/ProviderAssemblies 20 | 21 | #> 22 | function Remove-AllPackageManagementProviders { 23 | rm $Env:ProgramFiles/PackageManagement/ProviderAssemblies/*.exe 24 | rm $Env:LocalAppData/PackageManagement/ProviderAssemblies/*.exe 25 | rm $Env:ProgramFiles/PackageManagement/ProviderAssemblies/*.dll 26 | rm $Env:LocalAppData/PackageManagement/ProviderAssemblies/*.dll 27 | } 28 | 29 | 30 | <# 31 | .SYNOPSIS 32 | Checks to see if the PackageManagement Module is loaded. 33 | 34 | #> 35 | function Test-IsPackageManagementLoaded { 36 | if( get-module -name PackageManagement ) { 37 | return $true 38 | } 39 | 40 | return $false 41 | } 42 | 43 | <# 44 | .SYNOPSIS 45 | Imports the PackageManagement Module (using the environment variable to select the right one) 46 | #> 47 | function Import-PackageManagement { 48 | <# 49 | PackageManagement tests should have the $moduleLocation set by the calling script 50 | otherwise it will use the default (loading PackageManagement from the PSModulePath) 51 | #> 52 | 53 | if (-not $env:PMModuleTest ) { 54 | $env:PMModuleTest = "PackageManagement" 55 | } 56 | 57 | echo "Importing PackageManagement Module from $env:PMModuleTest" 58 | ipmo $env:PMModuleTest 59 | return $true 60 | } 61 | 62 | Export-ModuleMember * 63 | -------------------------------------------------------------------------------- /Test/ModuleTests/tools/DnsShim.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OneGet/oneget/d25ee92d7b3195c0bcf6f0a6162bd928418f20f6/Test/ModuleTests/tools/DnsShim.exe -------------------------------------------------------------------------------- /Test/ModuleTests/tools/Shim32.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OneGet/oneget/d25ee92d7b3195c0bcf6f0a6162bd928418f20f6/Test/ModuleTests/tools/Shim32.dll -------------------------------------------------------------------------------- /Test/ModuleTests/tools/Shim64.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OneGet/oneget/d25ee92d7b3195c0bcf6f0a6162bd928418f20f6/Test/ModuleTests/tools/Shim64.dll -------------------------------------------------------------------------------- /Test/ModuleTests/tools/hosts.txt: -------------------------------------------------------------------------------- 1 | *.microsoft.com 2 | www.powershellgallery.com 3 | *.chocolatey.org 4 | oneget.org 5 | * -------------------------------------------------------------------------------- /Test/ModuleTests/tools/snremove.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OneGet/oneget/d25ee92d7b3195c0bcf6f0a6162bd928418f20f6/Test/ModuleTests/tools/snremove.exe -------------------------------------------------------------------------------- /Test/OneGetTestProvider/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | // 14 | 15 | using System.Reflection; 16 | using System.Runtime.InteropServices; 17 | 18 | // General Information about an assembly is controlled through the following 19 | // set of attributes. Change these attribute values to modify the information 20 | // associated with an assembly. 21 | 22 | [assembly: AssemblyTitle("$project.$provider")] 23 | [assembly: AssemblyDescription("PackageManagement package provider: $provider.")] 24 | [assembly: AssemblyConfiguration("")] 25 | [assembly: AssemblyCompany("$project")] 26 | [assembly: AssemblyProduct("$project.$provider")] 27 | [assembly: AssemblyCopyright("Copyright $project © 2014")] 28 | [assembly: AssemblyTrademark("")] 29 | [assembly: AssemblyCulture("")] 30 | 31 | // Setting ComVisible to false makes the types in this assembly not visible 32 | // to COM components. If you need to access a type in this assembly from 33 | // COM, set the ComVisible attribute to true on that type. 34 | 35 | [assembly: ComVisible(false)] 36 | 37 | // The following GUID is for the ID of the typelib if this project is exposed to COM 38 | 39 | [assembly: Guid("bff90b5a-cb46-49b3-a3d5-5df99bf23017")] 40 | 41 | // Version information for an assembly consists of the following four values: 42 | // 43 | // Major Version 44 | // Minor Version 45 | // Build Number 46 | // Revision 47 | // 48 | // You can specify all the values or you can default the Build and Revision Numbers 49 | // by using the '*' as shown below: 50 | // [assembly: AssemblyVersion("1.0.*")] 51 | 52 | [assembly: AssemblyVersion("1.0.0.0")] 53 | [assembly: AssemblyFileVersion("1.0.0.0")] 54 | -------------------------------------------------------------------------------- /Test/OneGetTestProvider/Sdk/ErrorCategory.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | // 14 | 15 | namespace Microsoft.PackageManagement.OneGetTestProvider.Sdk { 16 | public enum ErrorCategory { 17 | NotSpecified, 18 | OpenError, 19 | CloseError, 20 | DeviceError, 21 | DeadlockDetected, 22 | InvalidArgument, 23 | InvalidData, 24 | InvalidOperation, 25 | InvalidResult, 26 | InvalidType, 27 | MetadataError, 28 | NotImplemented, 29 | NotInstalled, 30 | ObjectNotFound, 31 | OperationStopped, 32 | OperationTimeout, 33 | SyntaxError, 34 | ParserError, 35 | PermissionDenied, 36 | ResourceBusy, 37 | ResourceExists, 38 | ResourceUnavailable, 39 | ReadError, 40 | WriteError, 41 | FromStdErr, 42 | SecurityError, 43 | ProtocolError, 44 | ConnectionError, 45 | AuthenticationError, 46 | LimitsExceeded, 47 | QuotaExceeded, 48 | NotEnabled, 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /Test/OneGetTestProvider/provider.manifest: -------------------------------------------------------------------------------- 1 |  2 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Test/PSL/win10/PSL.json: -------------------------------------------------------------------------------- 1 | { 2 | "PowerShell": { 3 | "displayName": "PowerShell_6.1.2", 4 | "source": "https://github.com/PowerShell/PowerShell/releases/download/v6.1.2/PowerShell-6.1.2-win-x64.msi", 5 | "hash": { 6 | "algorithm": "sha512", 7 | "hashCode": "DD66C1E67BD5F3B74D97A5F9B0764B0D2DB840E9DE52FABD17D975C28CD38046957EB0C0DDDFB76C48E8AEAECDBB1A7C8B77454FA9875A71C7995E13B40944DF" 8 | }, 9 | "summary": "Powershell", 10 | "type": "msi", 11 | "version": "6.1.2" 12 | } 13 | } -------------------------------------------------------------------------------- /Test/PSL/win81/PSL.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OneGet/oneget/d25ee92d7b3195c0bcf6f0a6162bd928418f20f6/Test/PSL/win81/PSL.json -------------------------------------------------------------------------------- /Test/Packages_100.txt: -------------------------------------------------------------------------------- 1 | MediaProB2BService 2 | QT2K.SupportLibraries.EnumerationLibrary.NET4 3 | NBM 4 | anic.JChemUtils.CompoundRegistration 5 | Microsoft.VisualStudio.TextTemplating.Interfaces.10.0 6 | HEBI.C 7 | Plato.Cache 8 | Fody 9 | Heimdall 10 | Nancy.Linker 11 | murmurhash3js.TypeScript.DefinitelyTyped 12 | gulp-cached.TypeScript.DefinitelyTyped 13 | Chaos.WebApi 14 | ThirtyNineEighty.BinarySerializer 15 | angular-applicationinsights 16 | ErrorUnit.Injector_SimpleInjector 17 | SAPP 18 | SimpleJsonApi 19 | AzureTable.LiteClient 20 | Microsoft.GVFS.GvFlt 21 | poco_wp8_1 22 | Narato.Correlations 23 | SFA.Roatp.Api.Client 24 | RestSharp.Rpc 25 | jQuery.Color 26 | ASP.NET-StatusBoard.AspNetCore 27 | cloudscribe.SimpleContent.Storage.EFCore.pgsql 28 | xunit.console 29 | LazyValue 30 | GitHub 31 | UmbracoEx 32 | NLog.Interface 33 | DevLib.DirectoryServices 34 | libtorrent4tsunami 35 | GoldenEye.Backend.Core 36 | Selenium.WebDriver.Extensions 37 | ExcelReport 38 | EntityFramework.CommonTools 39 | Menulab.Discussions 40 | guard_claws 41 | sweetalert.TypeScript.DefinitelyTyped 42 | Desafio131LuisBeltran 43 | hiqpdf.free 44 | Rfc822 45 | FunScript.TypeScript.Binding.knockout_validation 46 | gitlink 47 | Toolkit.Elections 48 | Test123456789 49 | SlimerJS 50 | NetFusion.Common 51 | Synology.NET 52 | Moon.DAL.EF 53 | XamlConverters 54 | zeroc.freeze.v120 55 | LoveSeat 56 | SD.IOC.UnityProvider 57 | Retyped.rebass 58 | Nett.StrongNamed 59 | Dapper.Entity 60 | BryanVam.Data.Entity 61 | umbraco.TypeScript.DefinitelyTyped 62 | Tabster.Data 63 | react-scrollbar.TypeScript.DefinitelyTyped 64 | twitter.bootstrap.mvc4.sample 65 | Carbon.Geometry 66 | SMA.Tools4.Xpo.Server.Core.Service 67 | Takenet.Elephant.Sql.PostgreSql 68 | Paradigm.Core.Assemblies 69 | Retyped.node-waves 70 | Microsoft.AspNet.Mvc.Core 71 | Enfold.Javascript 72 | BGreyling.Utilities.Patterns 73 | php-7.0.v140 74 | OctoPack.MigratorDotnet 75 | SeModFx-Stable 76 | com.qiny.donetbar 77 | FastSmsSdk 78 | AntiXsNewSchema 79 | eXpandJobShedulerJobs 80 | TheDylanKit.Policies 81 | Atlantis.Net.Irc 82 | Roccat-Talk 83 | Gear.EntityFramework 84 | Cake.Gem 85 | Async.EventWay.Infrastructure.CosmosDb 86 | FileHelpers-Stable 87 | Retyped.promise.prototype.finally 88 | DbEntry 89 | ASPConf 90 | Jim.DependencyResolver 91 | StopWatch 92 | AspNetWebApi.ApiGee 93 | Hdq.RestBus.Core 94 | Slycoder.Portable.Networking 95 | RaisingStudio.Modules.LightningDB 96 | FluentHttpRequest 97 | Xamarin.Facebook.iOS 98 | Equals.Fody 99 | MyLib1 100 | HoveyTech.Data.EfCore.Autofac 101 | -------------------------------------------------------------------------------- /Test/Unit/Providers/Dependencies/BigDependenciesLoop/ModuleA.1.0.nupkg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OneGet/oneget/d25ee92d7b3195c0bcf6f0a6162bd928418f20f6/Test/Unit/Providers/Dependencies/BigDependenciesLoop/ModuleA.1.0.nupkg -------------------------------------------------------------------------------- /Test/Unit/Providers/Dependencies/BigDependenciesLoop/ModuleB.1.0.nupkg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OneGet/oneget/d25ee92d7b3195c0bcf6f0a6162bd928418f20f6/Test/Unit/Providers/Dependencies/BigDependenciesLoop/ModuleB.1.0.nupkg -------------------------------------------------------------------------------- /Test/Unit/Providers/Dependencies/BigDependenciesLoop/ModuleC.1.0.nupkg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OneGet/oneget/d25ee92d7b3195c0bcf6f0a6162bd928418f20f6/Test/Unit/Providers/Dependencies/BigDependenciesLoop/ModuleC.1.0.nupkg -------------------------------------------------------------------------------- /Test/Unit/Providers/Dependencies/BigDependenciesLoop/ModuleD.1.0.nupkg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OneGet/oneget/d25ee92d7b3195c0bcf6f0a6162bd928418f20f6/Test/Unit/Providers/Dependencies/BigDependenciesLoop/ModuleD.1.0.nupkg -------------------------------------------------------------------------------- /Test/Unit/Providers/Dependencies/SimpleDependenciesLoop/ModuleWithDependenciesLoop.1.0.nupkg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OneGet/oneget/d25ee92d7b3195c0bcf6f0a6162bd928418f20f6/Test/Unit/Providers/Dependencies/SimpleDependenciesLoop/ModuleWithDependenciesLoop.1.0.nupkg -------------------------------------------------------------------------------- /Test/Unit/Providers/Dependencies/SimpleDependenciesLoop/RequiredModuleLoop.1.0.nupkg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OneGet/oneget/d25ee92d7b3195c0bcf6f0a6162bd928418f20f6/Test/Unit/Providers/Dependencies/SimpleDependenciesLoop/RequiredModuleLoop.1.0.nupkg -------------------------------------------------------------------------------- /Test/Unit/Providers/PSChained1Provider.psm1: -------------------------------------------------------------------------------- 1 | function Find-Package { 2 | [CmdletBinding()] 3 | param( 4 | [string] $name, 5 | [string] $requiredVersion, 6 | [string] $minimumVersion, 7 | [string] $maximumVersion 8 | ) 9 | write-debug "In PSChained1Provider - Find-Package $name - $requiredVersion" 10 | 11 | if( -not $($request.Services) ) { 12 | # make sure we can see the provider services object. 13 | write-debug "Provider Services : NULL" 14 | } 15 | 16 | # create a request object for the chained call 17 | $req = New-Request -sources @( "http://nuget.org/api/v2" ) 18 | 19 | if( (-not $name) -or ($name -eq "zlib")) { 20 | $pkgs = $request.FindPackageByCanonicalId("nuget:zlib/1.2.8.7#http://nuget.org/api/v2", $req); 21 | foreach( $pkg in $pkgs ) { 22 | 23 | $deps = (new-Object -TypeName System.Collections.ArrayList) 24 | foreach( $d in $pkg.Dependencies ) { 25 | write-debug "DEPENDENCY: $d" 26 | # add each dependency, but say it's from us. 27 | $deps.Add( (new-dependency "PSChained1Provider" $request.Services.ParsePackageName($d) $request.Services.ParsePackageVersion($d) "my-source" $null) ) 28 | 29 | } 30 | 31 | $p = new-softwareidentity "zlib" $pkg.Name $pkg.Version $pkg.VersionScheme "my-source" $pkg.Summary -dependencies $deps 32 | 33 | Write-Output $p 34 | } 35 | } 36 | 37 | # return the redist package: 38 | if( $name -eq "zlib.redist" -and $requiredVersion -eq "1.2.8.7" ) { 39 | $pkgs = $request.FindPackageByCanonicalId("nuget:zlib.redist/1.2.8.7#http://nuget.org/api/v2", $req); 40 | foreach( $pkg in $pkgs ) { 41 | $deps = (new-Object -TypeName System.Collections.ArrayList) 42 | foreach( $d in $pkg.Dependencies ) { 43 | # add each dependency, but say it's from us. 44 | $deps.Add( (new-dependency "PSChained1Provider" $request.Services.ParsePackageName($d) $request.Services.ParsePackageVersion($d) "my-source" $null) ) 45 | } 46 | 47 | $p = new-softwareidentity "zlib.redist" $pkg.Name $pkg.Version $pkg.VersionScheme "my-source" $pkg.Summary -dependencies $deps 48 | 49 | Write-Output $p 50 | } 51 | } 52 | 53 | } 54 | 55 | function Initialize-Provider { 56 | param() 57 | write-debug "In PSChained1Provider - Initialize-Provider" 58 | } 59 | 60 | function Get-PackageProviderName { 61 | return "PSChained1Provider" 62 | } 63 | -------------------------------------------------------------------------------- /Test/Unit/Providers/PSOneGetTestProvider/1.1/OneGetTestProvider.psm1: -------------------------------------------------------------------------------- 1 | $providerName ="OneGetTest" 2 | 3 | function Initialize-Provider { write-debug "In $($Providername) - Initialize-Provider" } 4 | function Get-PackageProviderName { return $Providername } 5 | -------------------------------------------------------------------------------- /Test/Unit/Providers/PSOneGetTestProvider/1.1/PSOneGetTestProvider.psd1: -------------------------------------------------------------------------------- 1 | @{ 2 | ModuleVersion = '1.1' 3 | GUID = '12312312-4a6c-43c5-ba3f-619b18bbb123' 4 | Author = 'Microsoft Corporation' 5 | CompanyName = 'Microsoft Corporation' 6 | Copyright = '© Microsoft Corporation. All rights reserved.' 7 | PowerShellVersion = '3.0' 8 | VariablesToExport = "*" 9 | PrivateData = @{ 10 | "PackageManagementProviders" = @( 11 | 'OneGetTestProvider.psm1' 12 | ) 13 | } 14 | } 15 | 16 | -------------------------------------------------------------------------------- /Test/Unit/Providers/PSOneGetTestProvider/1.1/PSOneGetTestProvider.psm1: -------------------------------------------------------------------------------- 1 | $providerName ="OneGetTest" 2 | 3 | function Initialize-Provider { write-debug "In $($Providername) - Initialize-Provider" } 4 | function Get-PackageProviderName { return $Providername } 5 | -------------------------------------------------------------------------------- /Test/Unit/Providers/PSOneGetTestProvider/3.5/OneGetTestProvider.psm1: -------------------------------------------------------------------------------- 1 | $providerName ="OneGetTest" 2 | 3 | function Initialize-Provider { write-debug "In $($Providername) - Initialize-Provider" } 4 | function Get-PackageProviderName { return $Providername } 5 | function Get-InstalledPackage { Get-Process -id "wrongid" } 6 | -------------------------------------------------------------------------------- /Test/Unit/Providers/PSOneGetTestProvider/3.5/PSOneGetTestProvider.psd1: -------------------------------------------------------------------------------- 1 | @{ 2 | ModuleVersion = '3.5' 3 | GUID = '12312312-4a6c-43c5-ba3f-619b18bbb123' 4 | Author = 'Microsoft Corporation' 5 | CompanyName = 'Microsoft Corporation' 6 | Copyright = '© Microsoft Corporation. All rights reserved.' 7 | PowerShellVersion = '3.0' 8 | VariablesToExport = "*" 9 | PrivateData = @{ 10 | "PackageManagementProviders" = @( 11 | 'OneGetTestProvider.psm1' 12 | ) 13 | } 14 | } 15 | 16 | -------------------------------------------------------------------------------- /Test/Unit/Providers/PSOneGetTestProvider/3.5/PSOneGetTestProvider.psm1: -------------------------------------------------------------------------------- 1 | $providerName ="OneGetTest" 2 | 3 | function Initialize-Provider { write-debug "In $($Providername) - Initialize-Provider" } 4 | function Get-PackageProviderName { return $Providername } 5 | -------------------------------------------------------------------------------- /Test/Unit/Providers/PSOneGetTestProvider/9.9/PSOneGetTestProvider.psd1: -------------------------------------------------------------------------------- 1 | @{ 2 | ModuleVersion = '9.9' 3 | GUID = '12312312-4a6c-43c5-ba3f-619b18bbb123' 4 | Author = 'Microsoft Corporation' 5 | CompanyName = 'Microsoft Corporation' 6 | Copyright = '© Microsoft Corporation. All rights reserved.' 7 | PowerShellVersion = '3.0' 8 | VariablesToExport = "*" 9 | PrivateData = @{ 10 | "PackageManagementProviders" = @( 11 | 'OneGetTestProvider.psm1' 12 | ) 13 | 14 | PSData = @{ 15 | # Tags applied to this module. These help with module discovery in online galleries. 16 | Tags = 'Packagemanagement','Provider' 17 | 18 | # A URL to the license for this module. 19 | LicenseUri = 'http://oneget.org/license' 20 | 21 | # A URL to the main website for this project. 22 | ProjectUri = 'http://oneget.org/project' 23 | 24 | # A URL to an icon representing this module. 25 | IconUri = 'http://oneget.org/icon' 26 | 27 | # ReleaseNotes of this module 28 | # ReleaseNotes = '' 29 | 30 | # External dependent modules of this module 31 | # ExternalModuleDependencies = '' 32 | } # End of PSData hashtable 33 | } 34 | } 35 | 36 | -------------------------------------------------------------------------------- /Test/Unit/Providers/PSOneGetTestProvider/9.9/PSOneGetTestProvider.psm1: -------------------------------------------------------------------------------- 1 | $providerName ="OneGetTest" 2 | 3 | function Initialize-Provider { write-debug "In $($Providername) - Initialize-Provider" } 4 | function Get-PackageProviderName { return $Providername } 5 | -------------------------------------------------------------------------------- /Test/Unit/Providers/Providers.psd1: -------------------------------------------------------------------------------- 1 | @{ 2 | RootModule = 'testproviders.psm1' 3 | ModuleVersion = '0.1' 4 | GUID = '12312312-4a6c-43c5-ba3f-619b18bbb123' 5 | Author = 'Microsoft Corporation' 6 | CompanyName = 'Microsoft Corporation' 7 | Copyright = '© Microsoft Corporation. All rights reserved.' 8 | PowerShellVersion = '3.0' 9 | VariablesToExport = "*" 10 | PrivateData = @{ 11 | "PackageManagementProviders" = @( 12 | 'TestPackageProvider.psm1', 13 | 'PSChained1Provider.psm1' 14 | ) 15 | } 16 | } 17 | 18 | -------------------------------------------------------------------------------- /Test/Unit/Providers/TestProviders.psm1: -------------------------------------------------------------------------------- 1 | # nothing to see here. 2 | -------------------------------------------------------------------------------- /UpdatePackage.psm1: -------------------------------------------------------------------------------- 1 | function Update-Package 2 | { 3 | [CmdletBinding()] 4 | Param 5 | ( 6 | # Name of the package 7 | [Parameter(Mandatory=$true, 8 | Position=0)] 9 | [string[]] 10 | $Name, 11 | 12 | # Provider associated with the package 13 | [Alias("Provider")] 14 | [string] 15 | $ProviderName 16 | ) 17 | 18 | DynamicParam { 19 | $paramDictionary = New-Object System.Management.Automation.RuntimeDefinedParameterDictionary 20 | 21 | # Get the required dynamic parameter for install 22 | if (-not ([string]::IsNullOrWhiteSpace($ProviderName))) 23 | { 24 | $providerObject = Get-PackageProvider -Name $ProviderName | Select -First 1 25 | 26 | if ($null -ne $providerObject -and ($providerObject.DynamicOptions -ne $null -and $providerObject.DynamicOptions.Count -gt 0)) 27 | { 28 | foreach ($option in $providerObject.DynamicOptions) 29 | { 30 | $optionalAttribute = New-Object System.Management.Automation.ParameterAttribute 31 | $optionalAttribute.Mandatory = $option.IsRequired 32 | 33 | $attributes = New-Object System.Collections.ObjectModel.Collection[System.Attribute] 34 | $attributes.Add($optionalAttribute) 35 | 36 | $param = New-Object System.Management.Automation.RuntimeDefinedParameter($option.Name, [System.Object], $attributes) 37 | 38 | $paramDictionary.Add($option.Name, $param) 39 | } 40 | } 41 | } 42 | 43 | return $paramDictionary 44 | } 45 | 46 | Process { 47 | $packagesToBeUpdated = Get-Package @PSBoundParameters 48 | 49 | foreach ($package in $packagesToBeUpdated) 50 | { 51 | $possibleNewPackage = Find-Package -Name $package.Name -ProviderName $package.ProviderName 52 | $possibleNewVersion = [version]$possibleNewPackage.Version 53 | $version = [version]$package.Version 54 | 55 | if ($possibleNewVersion -gt $version) 56 | { 57 | Write-Verbose "Need to update since $possibleNewVersion is found for $($package.Name) which has version $($package.Version)" 58 | $PSBoundParameters["RequiredVersion"] = $possibleNewVersion 59 | Install-Package @PSBoundParameters 60 | } 61 | else 62 | { 63 | Write-Verbose "$($package.Name) has the latest version $possibleNewVersion" 64 | } 65 | } 66 | } 67 | } -------------------------------------------------------------------------------- /assembly-version.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | using System.Reflection; 15 | 16 | // Version information for an assembly consists of the following four values: 17 | // 18 | // Major Version 19 | // Minor Version 20 | // Build Number 21 | // Revision 22 | [assembly: AssemblyVersion("1.16.12.45267")] 23 | [assembly: AssemblyFileVersion("1.16.12.45267")] 24 | -------------------------------------------------------------------------------- /assets/OneGetArchitecture.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OneGet/oneget/d25ee92d7b3195c0bcf6f0a6162bd928418f20f6/assets/OneGetArchitecture.PNG -------------------------------------------------------------------------------- /docs/README.md: -------------------------------------------------------------------------------- 1 | 2 | # PackageManagement (aka OneGet) 3 | 4 | 5 | - PackageManagement [Overview][overview] 6 | - OneGet [Cmdlets][cmdlets] 7 | - [Try some samples][samples] 8 | - Write a PowerShell-based [OneGet provider][writeprovider] 9 | - Read our [General Q and A](https://github.com/OneGet/oneget/wiki/Q-and-A) 10 | - [General Troubleshooting](https://github.com/OneGet/oneget/wiki/General-Troubleshooting) 11 | - Check out more help information [in our wiki page](https://github.com/oneget/oneget/wiki) 12 | 13 | ## Links 14 | - Changes in [WMF 5.0][WMI50] 15 | - Changes in [WMF 5.1][WMI51] 16 | 17 | 18 | [overview]: ../readme.md#PackageManagement-(aka-OneGet) 19 | [cmdlets]:https://msdn.microsoft.com/en-us/powershell/gallery/psget/oneget/packagemanagement_cmdlets 20 | [samples]: ../readme.md#Let's-Try-it 21 | [writeprovider]: ./writepowershellbasedprovider.md 22 | [WMI50]: https://msdn.microsoft.com/en-us/powershell/wmf/5.0/oneget_cmdlets 23 | [WMI51]:https://msdn.microsoft.com/en-us/powershell/wmf/5.1/package-management-improvements 24 | -------------------------------------------------------------------------------- /global.json: -------------------------------------------------------------------------------- 1 | { 2 | "sdk": { 3 | "version": "8.0.202" 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /nuget.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /owners.txt: -------------------------------------------------------------------------------- 1 | ; this is an example owners.txt file which can be added at any level in the repo to indicate owners of a subtree 2 | ; this file is used by ownership enforcer to determine reviewers to add to a pull request 3 | ; you can add comments using ; as prefix 4 | ; introduce each owner in a separate line with his/her alias (not email address) 5 | ; prefixing an alias with * means that the owner will not be automatically added as a reviewer to pull requests to reduce noise, but can still be manually added and can sign off if necessary 6 | ; to learn more you can read https://microsoft.sharepoint.com/teams/WAG/EngSys/EngPipeline/cdp/SitePages/Configure%20checkin%20gates.aspx 7 | ; if you do not wish to use this feature then you can delete this file 8 | ; example (pretend the following lines are not commented): 9 | ; 10 | ; developer1 11 | ; developer2 12 | ; *developer3 13 | annavied 14 | americks 15 | adityap 16 | *slee 17 | -------------------------------------------------------------------------------- /solution.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | $(registry:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\3\PowerShellEngine@PowerShellVersion) 6 | 10 | v4.5 11 | v4.0 12 | 13 | false 14 | 1591,3002,3003,3008,3009 15 | true 16 | FRAMEWORK$(TargetFrameworkVersion.Replace(".","")) 17 | output\$(Configuration)\bin\ 18 | 19 | $(MSBuildThisFileDirectory) 20 | 21 | $(SolutionDir)output\$(Configuration)\bin\ 22 | $(SolutionDir)intermediate\$(Configuration)\$(AssemblyName)\ 23 | $(BaseIntermediateOutputPath) 24 | $(OutputPath)$(AssemblyName).XML 25 | for /f "delims=" %25%25a in ('powershell "$p = ((Get-ItemProperty -Path HKCU:\Software\PackageManagement\tools\MT.EXE -Name Path -ea 0).Path) ; if( -not $p ) { $p = ((dir ${env:ProgramFiles(x86)} -recurse -ea 0| where -property name -eq mt.exe | select -first 1 ).FullName) ; $null = mkdir -Path HKCU:\Software\PackageManagement\tools\MT.EXE -Force ; $null = New-ItemProperty -Path HKCU:\Software\PackageManagement\tools\MT.EXE -Name Path -Value $p -force } ; $p"') do @set MTEXE=%25%25a 26 | 27 | -------------------------------------------------------------------------------- /src/Microsoft.PackageManagement.ArchiverProviders/Compression/ArchiveException.cs: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------- 2 | // 3 | // Copyright (c) 1999, Microsoft Corporation. All rights reserved. 4 | // 5 | // 6 | // Part of the Deployment Tools Foundation project. 7 | // 8 | //--------------------------------------------------------------------- 9 | 10 | namespace Microsoft.PackageManagement.Archivers.Internal.Compression 11 | { 12 | using System; 13 | using System.IO; 14 | 15 | /// 16 | /// Base exception class for compression operations. Compression libraries should 17 | /// derive subclass exceptions with more specific error information relevent to the 18 | /// file format. 19 | /// 20 | public class ArchiveException : IOException 21 | { 22 | /// 23 | /// Creates a new ArchiveException with a specified error message and a reference to the 24 | /// inner exception that is the cause of this exception. 25 | /// 26 | /// The message that describes the error. 27 | /// The exception that is the cause of the current exception. If the 28 | /// innerException parameter is not a null reference (Nothing in Visual Basic), the current exception 29 | /// is raised in a catch block that handles the inner exception. 30 | public ArchiveException(string message, Exception innerException) 31 | : base(message, innerException) 32 | { 33 | } 34 | 35 | /// 36 | /// Creates a new ArchiveException with a specified error message. 37 | /// 38 | /// The message that describes the error. 39 | public ArchiveException(string message) 40 | : this(message, null) 41 | { 42 | } 43 | 44 | /// 45 | /// Creates a new ArchiveException. 46 | /// 47 | public ArchiveException() 48 | : this(null, null) 49 | { 50 | } 51 | 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/Microsoft.PackageManagement.ArchiverProviders/Compression/CompressionLevel.cs: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------- 2 | // 3 | // Copyright (c) 1999, Microsoft Corporation. All rights reserved. 4 | // 5 | // 6 | // Part of the Deployment Tools Foundation project. 7 | // 8 | //--------------------------------------------------------------------- 9 | 10 | namespace Microsoft.PackageManagement.Archivers.Internal.Compression 11 | { 12 | /// 13 | /// Specifies the compression level ranging from minimum compression to 14 | /// maximum compression, or no compression at all. 15 | /// 16 | /// 17 | /// Although only four values are enumerated, any integral value between 18 | /// and can also be used. 19 | /// 20 | public enum CompressionLevel 21 | { 22 | /// Do not compress files, only store. 23 | None = 0, 24 | 25 | /// Minimum compression; fastest. 26 | Min = 1, 27 | 28 | /// A compromise between speed and compression efficiency. 29 | Normal = 6, 30 | 31 | /// Maximum compression; slowest. 32 | Max = 10 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/Microsoft.PackageManagement.ArchiverProviders/Compression/SafeNativeMethods.cs: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------- 2 | // 3 | // Copyright (c) 1999, Microsoft Corporation. All rights reserved. 4 | // 5 | // 6 | // Part of the Deployment Tools Foundation project. 7 | // 8 | //--------------------------------------------------------------------- 9 | 10 | namespace Microsoft.PackageManagement.Archivers.Internal.Compression 11 | { 12 | using System.Runtime.InteropServices; 13 | using System.Security; 14 | 15 | #if !CORECLR 16 | [SuppressUnmanagedCodeSecurity] 17 | #endif 18 | internal static class SafeNativeMethods 19 | { 20 | #if !CORECLR 21 | [DllImport("kernel32.dll", SetLastError = true)] 22 | #else 23 | [DllImport("api-ms-win-core-kernel32-legacy-l1-1-1.dll", SetLastError=true)] 24 | #endif 25 | [return: MarshalAs(UnmanagedType.Bool)] 26 | internal static extern bool DosDateTimeToFileTime( 27 | short wFatDate, short wFatTime, out long fileTime); 28 | 29 | #if !CORECLR 30 | [DllImport("kernel32.dll", SetLastError = true)] 31 | #else 32 | [DllImport("api-ms-win-core-kernel32-legacy-l1-1-1.dll", SetLastError=true)] 33 | #endif 34 | [return: MarshalAs(UnmanagedType.Bool)] 35 | internal static extern bool FileTimeToDosDateTime( 36 | ref long fileTime, out short wFatDate, out short wFatTime); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/Microsoft.PackageManagement.ArchiverProviders/Compression/Zip/ZipException.cs: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------- 2 | // 3 | // Copyright (c) 1999, Microsoft Corporation. All rights reserved. 4 | // 5 | // 6 | // Part of the Deployment Tools Foundation project. 7 | // 8 | //--------------------------------------------------------------------- 9 | 10 | namespace Microsoft.PackageManagement.Archivers.Internal.Compression.Zip 11 | { 12 | using System; 13 | 14 | /// 15 | /// Exception class for zip operations. 16 | /// 17 | public class ZipException : ArchiveException 18 | { 19 | /// 20 | /// Creates a new ZipException with a specified error message and a reference to the 21 | /// inner exception that is the cause of this exception. 22 | /// 23 | /// The message that describes the error. 24 | /// The exception that is the cause of the current exception. If the 25 | /// innerException parameter is not a null reference (Nothing in Visual Basic), the current exception 26 | /// is raised in a catch block that handles the inner exception. 27 | public ZipException(string message, Exception innerException) 28 | : base(message, innerException) { } 29 | 30 | /// 31 | /// Creates a new ZipException with a specified error message. 32 | /// 33 | /// The message that describes the error. 34 | public ZipException(string message) 35 | : this(message, null) { } 36 | 37 | /// 38 | /// Creates a new ZipException. 39 | /// 40 | public ZipException() 41 | : this(null, null) { } 42 | 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/Microsoft.PackageManagement.ArchiverProviders/Microsoft.PackageManagement.ArchiverProviders.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net472 5 | true 6 | true 7 | Microsoft.PackageManagement.ArchiverProviders 8 | ../signing/35MSSharedLib1024.snk 9 | true 10 | Microsoft.PackageManagement.ArchiverProviders 11 | win7-x64;win81-x64;win10-x64 12 | false 13 | false 14 | false 15 | false 16 | false 17 | false 18 | false 19 | false 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /src/Microsoft.PackageManagement.ArchiverProviders/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | // 14 | 15 | using System.Reflection; 16 | using System.Runtime.InteropServices; 17 | 18 | // General Information about an assembly is controlled through the following 19 | // set of attributes. Change these attribute values to modify the information 20 | // associated with an assembly. 21 | 22 | [assembly: AssemblyTitle("Microsoft.PackageManagement.Archivers")] 23 | [assembly: AssemblyDescription("Archiver providers for Zip and Cab files")] 24 | [assembly: AssemblyConfiguration("")] 25 | [assembly: AssemblyCompany("Microsoft")] 26 | [assembly: AssemblyProduct("Microsoft.PackageManagement.Archivers")] 27 | [assembly: AssemblyCopyright("Copyright Microsoft © 2015")] 28 | [assembly: AssemblyTrademark("")] 29 | [assembly: AssemblyCulture("")] 30 | [assembly: AssemblyFileVersionAttribute("3.0.0.0")] 31 | [assembly: AssemblyVersion("3.0.0.0")] 32 | 33 | // Setting ComVisible to false makes the types in this assembly not visible 34 | // to COM components. If you need to access a type in this assembly from 35 | // COM, set the ComVisible attribute to true on that type. 36 | 37 | [assembly: ComVisible(false)] 38 | 39 | // The following GUID is for the ID of the typelib if this project is exposed to COM 40 | 41 | [assembly: Guid("78cd1d7f-c276-4dbf-bb7a-a323dd6d96ed")] -------------------------------------------------------------------------------- /src/Microsoft.PackageManagement.ArchiverProviders/provider.manifest: -------------------------------------------------------------------------------- 1 |  2 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/Microsoft.PackageManagement.CoreProviders/Bootstrap/Package.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | // 14 | 15 | namespace Microsoft.PackageManagement.Providers.Internal.Bootstrap { 16 | using System; 17 | using System.Collections.Generic; 18 | using PackageManagement.Internal.Packaging; 19 | using Packaging; 20 | 21 | internal class Package : Swid { 22 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 23 | internal Package(BootstrapRequest request, Swidtag swidtag) 24 | : base(request, swidtag) { 25 | } 26 | 27 | internal Package(BootstrapRequest request, IEnumerable mirrors) : base(request, mirrors) { 28 | } 29 | 30 | internal Package(BootstrapRequest request, IEnumerable mirrors) 31 | : base(request, mirrors) { 32 | } 33 | 34 | internal string Name { 35 | get { 36 | if (IsValid) { 37 | return _swidtag.Name; 38 | } 39 | return string.Empty; 40 | } 41 | } 42 | 43 | internal string Version { 44 | get { 45 | if (IsValid) { 46 | return _swidtag.Version ?? "0"; 47 | } 48 | return "0"; 49 | } 50 | } 51 | 52 | internal string VersionScheme { 53 | get { 54 | if (IsValid) { 55 | return _swidtag.VersionScheme ?? Iso19770_2.VersionScheme.Unknown; 56 | } 57 | return Iso19770_2.VersionScheme.Unknown; 58 | } 59 | } 60 | 61 | internal string Source {get; set;} 62 | } 63 | } -------------------------------------------------------------------------------- /src/Microsoft.PackageManagement.CoreProviders/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | // 14 | 15 | using System.Reflection; 16 | using System.Runtime.InteropServices; 17 | 18 | // General Information about an assembly is controlled through the following 19 | // set of attributes. Change these attribute values to modify the information 20 | // associated with an assembly. 21 | 22 | [assembly: AssemblyTitle("PackageManagement.CoreProviders")] 23 | [assembly: AssemblyDescription("")] 24 | [assembly: AssemblyConfiguration("")] 25 | [assembly: AssemblyCompany("")] 26 | [assembly: AssemblyProduct("CoreProviders")] 27 | [assembly: AssemblyCopyright("Copyright © 2015")] 28 | [assembly: AssemblyTrademark("")] 29 | [assembly: AssemblyCulture("")] 30 | [assembly: AssemblyFileVersionAttribute("3.0.0.0")] 31 | [assembly: AssemblyVersion("3.0.0.0")] 32 | // Setting ComVisible to false makes the types in this assembly not visible 33 | // to COM components. If you need to access a type in this assembly from 34 | // COM, set the ComVisible attribute to true on that type. 35 | 36 | [assembly: ComVisible(false)] 37 | 38 | // The following GUID is for the ID of the typelib if this project is exposed to COM 39 | 40 | [assembly: Guid("cbb49c87-7eb3-4054-acfe-783d13dd9755")] -------------------------------------------------------------------------------- /src/Microsoft.PackageManagement.CoreProviders/provider.manifest: -------------------------------------------------------------------------------- 1 |  2 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/Microsoft.PackageManagement.DscResources/MSFT_PackageManagement/MSFT_PackageManagement.schema.mfl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OneGet/oneget/d25ee92d7b3195c0bcf6f0a6162bd928418f20f6/src/Microsoft.PackageManagement.DscResources/MSFT_PackageManagement/MSFT_PackageManagement.schema.mfl -------------------------------------------------------------------------------- /src/Microsoft.PackageManagement.DscResources/MSFT_PackageManagement/MSFT_PackageManagement.schema.mof: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OneGet/oneget/d25ee92d7b3195c0bcf6f0a6162bd928418f20f6/src/Microsoft.PackageManagement.DscResources/MSFT_PackageManagement/MSFT_PackageManagement.schema.mof -------------------------------------------------------------------------------- /src/Microsoft.PackageManagement.DscResources/MSFT_PackageManagement/MSFT_PackageManagement.strings.psd1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OneGet/oneget/d25ee92d7b3195c0bcf6f0a6162bd928418f20f6/src/Microsoft.PackageManagement.DscResources/MSFT_PackageManagement/MSFT_PackageManagement.strings.psd1 -------------------------------------------------------------------------------- /src/Microsoft.PackageManagement.DscResources/MSFT_PackageManagementSource/MSFT_PackageManagementSource.psm1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OneGet/oneget/d25ee92d7b3195c0bcf6f0a6162bd928418f20f6/src/Microsoft.PackageManagement.DscResources/MSFT_PackageManagementSource/MSFT_PackageManagementSource.psm1 -------------------------------------------------------------------------------- /src/Microsoft.PackageManagement.DscResources/MSFT_PackageManagementSource/MSFT_PackageManagementSource.schema.mfl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OneGet/oneget/d25ee92d7b3195c0bcf6f0a6162bd928418f20f6/src/Microsoft.PackageManagement.DscResources/MSFT_PackageManagementSource/MSFT_PackageManagementSource.schema.mfl -------------------------------------------------------------------------------- /src/Microsoft.PackageManagement.DscResources/MSFT_PackageManagementSource/MSFT_PackageManagementSource.schema.mof: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OneGet/oneget/d25ee92d7b3195c0bcf6f0a6162bd928418f20f6/src/Microsoft.PackageManagement.DscResources/MSFT_PackageManagementSource/MSFT_PackageManagementSource.schema.mof -------------------------------------------------------------------------------- /src/Microsoft.PackageManagement.DscResources/MSFT_PackageManagementSource/MSFT_PackageManagementSource.strings.psd1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OneGet/oneget/d25ee92d7b3195c0bcf6f0a6162bd928418f20f6/src/Microsoft.PackageManagement.DscResources/MSFT_PackageManagementSource/MSFT_PackageManagementSource.strings.psd1 -------------------------------------------------------------------------------- /src/Microsoft.PackageManagement.DscResources/PackageManagementDscUtilities.strings.psd1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OneGet/oneget/d25ee92d7b3195c0bcf6f0a6162bd928418f20f6/src/Microsoft.PackageManagement.DscResources/PackageManagementDscUtilities.strings.psd1 -------------------------------------------------------------------------------- /src/Microsoft.PackageManagement.MetaProvider.PowerShell/Constants.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | // 14 | 15 | namespace Microsoft.PackageManagement.MetaProvider.PowerShell.Internal { 16 | internal static class Constants { 17 | internal const string ScriptStackTrace = "MSG:ScriptStackTrace"; 18 | internal const string ProviderNameUnknown = "(unknown)"; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/Microsoft.PackageManagement.MetaProvider.PowerShell/Dependency.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | // 14 | 15 | namespace Microsoft.PackageManagement.MetaProvider.PowerShell { 16 | public class Dependency { 17 | public string ProviderName {get; set;} 18 | public string PackageName {get; set;} 19 | public string Version {get; set;} 20 | public string Source {get; set;} 21 | public string AppliesTo {get; set;} 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/Microsoft.PackageManagement.MetaProvider.PowerShell/DynamicOption.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | // 14 | 15 | namespace Microsoft.PackageManagement.MetaProvider.PowerShell { 16 | using System; 17 | using System.Collections.Generic; 18 | using System.Linq; 19 | using Internal; 20 | using Microsoft.PackageManagement.Internal.Utility.Extensions; 21 | 22 | public class DynamicOption : Yieldable { 23 | public DynamicOption(OptionCategory category, string name, OptionType expectedType, bool isRequired, IEnumerable permittedValues) { 24 | Name = name; 25 | ExpectedType = expectedType; 26 | IsRequired = isRequired; 27 | PermittedValues = permittedValues; 28 | } 29 | 30 | public DynamicOption(string name, OptionType expectedType, bool isRequired, IEnumerable permittedValues) { 31 | Name = name; 32 | ExpectedType = expectedType; 33 | IsRequired = isRequired; 34 | PermittedValues = permittedValues; 35 | } 36 | 37 | 38 | public DynamicOption(OptionCategory category,string name, OptionType expectedType, bool isRequired) : this(category, name , expectedType, isRequired, null) { 39 | } 40 | 41 | public DynamicOption(string name, OptionType expectedType, bool isRequired) 42 | : this(name, expectedType, isRequired, null) { 43 | } 44 | 45 | 46 | public DynamicOption() { 47 | } 48 | 49 | public string Name {get; set;} 50 | public OptionType ExpectedType {get; set;} 51 | public bool IsRequired {get; set;} 52 | public IEnumerable PermittedValues {get; set;} 53 | 54 | public override bool YieldResult(PsRequest r) { 55 | if (r == null) { 56 | throw new ArgumentNullException("r"); 57 | } 58 | return r.YieldDynamicOption(Name, ExpectedType.ToString(), IsRequired) && PermittedValues.WhereNotNull().Select(each => each.ToString()).ToArray().All(v => r.YieldKeyValuePair(Name, v)); 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/Microsoft.PackageManagement.MetaProvider.PowerShell/Entity.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | // 14 | 15 | namespace Microsoft.PackageManagement.MetaProvider.PowerShell { 16 | using System; 17 | using System.Collections.Generic; 18 | using System.Linq; 19 | using Microsoft.PackageManagement.Internal.Utility.Extensions; 20 | 21 | public class Entity { 22 | public string Name {get; set;} 23 | public string RegId {get; set;} 24 | public string Role {get; set;} 25 | 26 | public IEnumerable Roles { 27 | get { 28 | return (string.IsNullOrWhiteSpace(Role) ? "unknown" : Role).Split(new[] {' '}, StringSplitOptions.RemoveEmptyEntries); 29 | } 30 | set 31 | { 32 | var values = value == null ? new string[0] : value.ToArray(); 33 | Role = ( values.Length == 0) ? "unknown" : value.JoinWith(" "); 34 | } 35 | } 36 | 37 | public string Thumbprint {get; set;} 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/Microsoft.PackageManagement.MetaProvider.PowerShell/Enums.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | // 14 | 15 | namespace Microsoft.PackageManagement.MetaProvider.PowerShell { 16 | public enum OptionCategory { 17 | Package = 0, 18 | Provider = 1, 19 | Source = 2, 20 | Install = 3 21 | } 22 | 23 | public enum OptionType { 24 | String = 0, 25 | StringArray = 1, 26 | Int = 2, 27 | Switch = 3, 28 | Folder = 4, 29 | File = 5, 30 | Path = 6, 31 | Uri = 7, 32 | SecureString = 8 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/Microsoft.PackageManagement.MetaProvider.PowerShell/Feature.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | // 14 | 15 | namespace Microsoft.PackageManagement.MetaProvider.PowerShell { 16 | using System; 17 | using System.Collections.Generic; 18 | using System.Linq; 19 | using Internal; 20 | 21 | public class Feature : Yieldable { 22 | private KeyValuePair _pair; 23 | 24 | public Feature(string name) : this(name, new string[0]) { 25 | } 26 | 27 | public Feature(string name, string value) : this(name, new[] {value}) { 28 | } 29 | 30 | public Feature(string name, string[] values) { 31 | _pair = new KeyValuePair(name, values); 32 | } 33 | 34 | public override bool YieldResult(PsRequest r) { 35 | if (r == null) { 36 | throw new ArgumentNullException("r"); 37 | } 38 | if (_pair.Value.Length == 0) { 39 | return r.YieldKeyValuePair(_pair.Key, null); 40 | } 41 | return _pair.Value.All(each => r.YieldKeyValuePair(_pair.Key, each)); 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/Microsoft.PackageManagement.MetaProvider.PowerShell/Link.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | // 14 | 15 | namespace Microsoft.PackageManagement.MetaProvider.PowerShell { 16 | public class Link { 17 | public string HRef {get; set;} 18 | public string Relationship {get; set;} 19 | public string MediaType {get; set;} 20 | public string Ownership {get; set;} 21 | public string Use {get; set;} 22 | public string AppliesToMedia {get; set;} 23 | public string Artifact {get; set;} 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/Microsoft.PackageManagement.MetaProvider.PowerShell/PackageSource.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | // 14 | 15 | namespace Microsoft.PackageManagement.MetaProvider.PowerShell { 16 | using System; 17 | using System.Collections; 18 | using Internal; 19 | 20 | public class PackageSource : Yieldable { 21 | public PackageSource(string name, string location, bool isTrusted, bool isRegistered, bool isValidated) { 22 | Name = name; 23 | Location = location; 24 | IsTrusted = isTrusted; 25 | IsRegistered = isRegistered; 26 | IsValidated = isValidated; 27 | } 28 | 29 | public PackageSource(string name, string location, bool isTrusted, bool isRegistered, bool isValidated, Hashtable details) 30 | : this(name, location, isTrusted, isRegistered, isValidated) { 31 | _details = details; 32 | } 33 | 34 | 35 | public PackageSource(string name, string location, bool isTrusted, bool isRegistered, Hashtable details) 36 | : this(name, location, isTrusted, isRegistered,false) { 37 | _details = details; 38 | } 39 | 40 | public string Name {get; set;} 41 | public string Location {get; set;} 42 | public bool IsTrusted {get; set;} 43 | public bool IsRegistered { get; set; } 44 | 45 | public bool IsValidated {get; set;} 46 | public override bool YieldResult(PsRequest r) { 47 | if (r == null) { 48 | throw new ArgumentNullException("r"); 49 | } 50 | 51 | return r.YieldPackageSource(Name, Location, IsTrusted, IsRegistered,IsValidated) && YieldDetails(r); 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/Microsoft.PackageManagement.MetaProvider.PowerShell/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | // 14 | 15 | using System.Reflection; 16 | using System.Runtime.CompilerServices; 17 | using System.Runtime.InteropServices; 18 | 19 | // General Information about an assembly is controlled through the following 20 | // set of attributes. Change these attribute values to modify the information 21 | // associated with an assembly. 22 | 23 | [assembly: AssemblyTitle("Microsoft.PackageManagement.MetaProvider.PowerShell")] 24 | [assembly: AssemblyDescription("PackageManagement Powershell MetaProvider")] 25 | [assembly: AssemblyConfiguration("")] 26 | [assembly: AssemblyCompany("Microsoft")] 27 | [assembly: AssemblyProduct("Microsoft.PackageManagement.MetaProvider.PowerShell")] 28 | [assembly: AssemblyCopyright("Copyright Microsoft © 2014")] 29 | [assembly: AssemblyTrademark("")] 30 | [assembly: AssemblyCulture("")] 31 | [assembly: AssemblyFileVersionAttribute("3.0.0.0")] 32 | [assembly: AssemblyVersion("3.0.0.0")] 33 | 34 | [assembly: InternalsVisibleTo(@"Microsoft.PackageManagement.Test" + @",PublicKey=0024000004800000940000000602000000240000525341310004000001000100b5fc90e7027f67871e773a8fde8938c81dd402ba65b9201d60593e96c492651e889cc13f1415ebb53fac1131ae0bd333c5ee6021672d9718ea31a8aebd0da0072f25d87dba6fc90ffd598ed4da35e44c398c454307e8e33b8426143daec9f596836f97c8f74750e5975c64e2189f45def46b2a2b1247adc3652bf5c308055da9")] 35 | 36 | // Setting ComVisible to false makes the types in this assembly not visible 37 | // to COM components. If you need to access a type in this assembly from 38 | // COM, set the ComVisible attribute to true on that type. 39 | 40 | [assembly: ComVisible(false)] 41 | 42 | // The following GUID is for the ID of the typelib if this project is exposed to COM 43 | 44 | [assembly: Guid("8a16b9f4-f12a-42ab-a396-3c966b896722")] 45 | -------------------------------------------------------------------------------- /src/Microsoft.PackageManagement.MetaProvider.PowerShell/Yieldable.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | // 14 | 15 | namespace Microsoft.PackageManagement.MetaProvider.PowerShell.Internal { 16 | using System.Collections; 17 | using System.Linq; 18 | using Microsoft.PackageManagement.Internal.Utility.Extensions; 19 | 20 | public abstract class Yieldable { 21 | protected Hashtable _details; 22 | 23 | public Hashtable Details { 24 | get { 25 | return _details ?? (_details = new Hashtable()); 26 | } 27 | internal set { 28 | _details = value; 29 | } 30 | } 31 | 32 | public abstract bool YieldResult(PsRequest r); 33 | 34 | protected virtual bool YieldDetails(PsRequest r) { 35 | if (_details != null && _details.Count > 0) { 36 | // we need to send this back as a set of key/path & value pairs. 37 | return _details.Flatten().All(kvp => r.YieldKeyValuePair(kvp.Key, kvp.Value)); 38 | } 39 | return true; 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/Microsoft.PackageManagement.MetaProvider.PowerShell/provider.manifest: -------------------------------------------------------------------------------- 1 |  2 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/Microsoft.PackageManagement.MsiProvider/Deployment/WindowsInstaller.Linq/Attributes.cs: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------- 2 | // 3 | // Copyright (c) 1999, Microsoft Corporation. All rights reserved. 4 | // 5 | // 6 | // Part of the Deployment Tools Foundation project. 7 | // 8 | //--------------------------------------------------------------------- 9 | 10 | namespace Microsoft.PackageManagement.Msi.Internal.Deployment.WindowsInstaller.Linq 11 | { 12 | using System; 13 | 14 | /// 15 | /// Apply to a subclass of QRecord to indicate the name of 16 | /// the table the record type is to be used with. 17 | /// 18 | /// 19 | /// If this attribute is not used on a record type, the default 20 | /// table name will be derived from the record type name. (An 21 | /// optional underscore suffix is stripped.) 22 | /// 23 | [AttributeUsage(AttributeTargets.Class, AllowMultiple = false)] 24 | internal class DatabaseTableAttribute : Attribute 25 | { 26 | /// 27 | /// Creates a new DatabaseTableAttribute for the specified table. 28 | /// 29 | /// name of the table associated with the record type 30 | public DatabaseTableAttribute(string table) 31 | { 32 | this.Table = table; 33 | } 34 | 35 | /// 36 | /// Gets or sets the table associated with the record type. 37 | /// 38 | public string Table { get; set; } 39 | } 40 | 41 | /// 42 | /// Apply to a property on a subclass of QRecord to indicate 43 | /// the name of the column the property is to be associated with. 44 | /// 45 | /// 46 | /// If this attribute is not used on a property, the default 47 | /// column name will be the same as the property name. 48 | /// 49 | [AttributeUsage(AttributeTargets.Property, AllowMultiple = false)] 50 | internal class DatabaseColumnAttribute : Attribute 51 | { 52 | /// 53 | /// Creates a new DatabaseColumnAttribute which maps a 54 | /// record property to a column. 55 | /// 56 | /// name of the column associated with the property 57 | public DatabaseColumnAttribute(string column) 58 | { 59 | this.Column = column; 60 | } 61 | 62 | /// 63 | /// Gets or sets the column associated with the record property. 64 | /// 65 | public string Column { get; set; } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /src/Microsoft.PackageManagement.MsiProvider/Deployment/WindowsInstaller/CustomActionAttribute.cs: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------- 2 | // 3 | // Copyright (c) 1999, Microsoft Corporation. All rights reserved. 4 | // 5 | // 6 | // Part of the Deployment Tools Foundation project. 7 | // 8 | //--------------------------------------------------------------------- 9 | 10 | namespace Microsoft.PackageManagement.Msi.Internal.Deployment.WindowsInstaller 11 | { 12 | using System; 13 | 14 | /// 15 | /// Marks a method as a custom action entry point. 16 | /// 17 | ///

18 | /// A custom action method must be defined as public and static, 19 | /// take a single object as a parameter, 20 | /// and return an enumeration value. 21 | ///

22 | [Serializable, AttributeUsage(AttributeTargets.Method)] 23 | internal sealed class CustomActionAttribute : Attribute 24 | { 25 | /// 26 | /// Name of the custom action entrypoint, or null if the same as the method name. 27 | /// 28 | private string name; 29 | 30 | /// 31 | /// Marks a method as a custom action entry point. 32 | /// 33 | public CustomActionAttribute() 34 | : this(null) 35 | { 36 | } 37 | 38 | /// 39 | /// Marks a method as a custom action entry point. 40 | /// 41 | /// Name of the function to be exported, 42 | /// defaults to the name of this method 43 | public CustomActionAttribute(string name) 44 | { 45 | this.name = name; 46 | } 47 | 48 | /// 49 | /// Gets or sets the name of the custom action entrypoint. A null 50 | /// value defaults to the name of the method. 51 | /// 52 | /// name of the custom action entrypoint, or null if none was specified 53 | public string Name 54 | { 55 | get 56 | { 57 | return this.name; 58 | } 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/Microsoft.PackageManagement.MsiProvider/Deployment/WindowsInstaller/InstallCost.cs: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------- 2 | // 3 | // Copyright (c) 1999, Microsoft Corporation. All rights reserved. 4 | // 5 | // 6 | // Microsoft.Deployment.WindowsInstaller.InstallCost struct. 7 | // 8 | //--------------------------------------------------------------------- 9 | 10 | namespace Microsoft.PackageManagement.Msi.Internal.Deployment.WindowsInstaller 11 | { 12 | using System.Diagnostics.CodeAnalysis; 13 | 14 | /// 15 | /// Represents a per-drive disk space cost for an installation. 16 | /// 17 | [SuppressMessage("Microsoft.Performance", "CA1815:OverrideEqualsAndOperatorEqualsOnValueTypes")] 18 | public struct InstallCost 19 | { 20 | private string driveName; 21 | private long cost; 22 | private long tempCost; 23 | 24 | /// 25 | /// Creates a new InstallCost object. 26 | /// 27 | /// name of the drive this cost data applies to 28 | /// installation cost on this drive, as a number of bytes 29 | /// temporary disk space required on this drive, as a number of bytes 30 | internal InstallCost(string driveName, long cost, long tempCost) 31 | { 32 | this.driveName = driveName; 33 | this.cost = cost; 34 | this.tempCost = tempCost; 35 | } 36 | 37 | /// 38 | /// The name of the drive this cost data applies to. 39 | /// 40 | public string DriveName 41 | { 42 | get 43 | { 44 | return this.driveName; 45 | } 46 | } 47 | 48 | /// 49 | /// The installation cost on this drive, as a number of bytes. 50 | /// 51 | public long Cost 52 | { 53 | get 54 | { 55 | return this.cost; 56 | } 57 | } 58 | 59 | /// 60 | /// The temporary disk space required on this drive, as a number of bytes. 61 | /// 62 | ///

63 | /// This temporary space requirement is space needed only for the duration 64 | /// of the installation, over the final footprint on disk. 65 | ///

66 | public long TempCost 67 | { 68 | get 69 | { 70 | return this.tempCost; 71 | } 72 | } 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /src/Microsoft.PackageManagement.MsiProvider/Deployment/WindowsInstaller/MediaDisk.cs: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------- 2 | // 3 | // Copyright (c) 1999, Microsoft Corporation. All rights reserved. 4 | // 5 | // 6 | // Microsoft.Deployment.WindowsInstaller.MediaDisk struct. 7 | // 8 | //--------------------------------------------------------------------- 9 | 10 | namespace Microsoft.PackageManagement.Msi.Internal.Deployment.WindowsInstaller 11 | { 12 | using System.Diagnostics.CodeAnalysis; 13 | 14 | /// 15 | /// Represents a media disk source of a product or a patch. 16 | /// 17 | [SuppressMessage("Microsoft.Performance", "CA1815:OverrideEqualsAndOperatorEqualsOnValueTypes")] 18 | public struct MediaDisk 19 | { 20 | private int diskId; 21 | private string volumeLabel; 22 | private string diskPrompt; 23 | 24 | /// 25 | /// Creates a new media disk. 26 | /// 27 | /// 28 | /// 29 | /// 30 | public MediaDisk(int diskId, string volumeLabel, string diskPrompt) 31 | { 32 | this.diskId = diskId; 33 | this.volumeLabel = volumeLabel; 34 | this.diskPrompt = diskPrompt; 35 | } 36 | 37 | /// 38 | /// Gets or sets the disk id of the media disk. 39 | /// 40 | public int DiskId 41 | { 42 | get { return this.diskId; } 43 | set { this.diskId = value; } 44 | } 45 | 46 | /// 47 | /// Gets or sets the volume label of the media disk. 48 | /// 49 | public string VolumeLabel 50 | { 51 | get { return this.volumeLabel; } 52 | set { this.volumeLabel = value; } 53 | } 54 | 55 | /// 56 | /// Gets or sets the disk prompt of the media disk. 57 | /// 58 | public string DiskPrompt 59 | { 60 | get { return this.diskPrompt; } 61 | set { this.diskPrompt = value; } 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/Microsoft.PackageManagement.MsiProvider/Deployment/WindowsInstaller/ValidationErrorInfo.cs: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------- 2 | // 3 | // Copyright (c) 1999, Microsoft Corporation. All rights reserved. 4 | // 5 | // 6 | // Microsoft.Deployment.WindowsInstaller.ValidationErrorInfo struct. 7 | // 8 | //--------------------------------------------------------------------- 9 | 10 | namespace Microsoft.PackageManagement.Msi.Internal.Deployment.WindowsInstaller 11 | { 12 | using System.Diagnostics.CodeAnalysis; 13 | 14 | /// 15 | /// Contains specific information about an error encountered by the , 16 | /// , or methods of the 17 | /// class. 18 | /// 19 | [SuppressMessage("Microsoft.Performance", "CA1815:OverrideEqualsAndOperatorEqualsOnValueTypes")] 20 | public struct ValidationErrorInfo 21 | { 22 | private ValidationError error; 23 | private string column; 24 | 25 | [SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 26 | internal ValidationErrorInfo(ValidationError error, string column) 27 | { 28 | this.error = error; 29 | this.column = column; 30 | } 31 | 32 | /// 33 | /// Gets the type of validation error encountered. 34 | /// 35 | public ValidationError Error 36 | { 37 | get 38 | { 39 | return this.error; 40 | } 41 | } 42 | 43 | /// 44 | /// Gets the column containing the error, or null if the error applies to the whole row. 45 | /// 46 | public string Column 47 | { 48 | get 49 | { 50 | return this.column; 51 | } 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/Microsoft.PackageManagement.MsiProvider/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | // 14 | 15 | using System.Reflection; 16 | using System.Runtime.InteropServices; 17 | 18 | // General Information about an assembly is controlled through the following 19 | // set of attributes. Change these attribute values to modify the information 20 | // associated with an assembly. 21 | 22 | [assembly: AssemblyTitle("MsiProvider")] 23 | [assembly: AssemblyDescription("")] 24 | [assembly: AssemblyConfiguration("")] 25 | [assembly: AssemblyCompany("")] 26 | [assembly: AssemblyProduct("MsiProvider")] 27 | [assembly: AssemblyCopyright("Copyright © 2014")] 28 | [assembly: AssemblyTrademark("")] 29 | [assembly: AssemblyCulture("")] 30 | [assembly: AssemblyFileVersionAttribute("3.0.0.0")] 31 | [assembly: AssemblyVersion("3.0.0.0")] 32 | 33 | // Setting ComVisible to false makes the types in this assembly not visible 34 | // to COM components. If you need to access a type in this assembly from 35 | // COM, set the ComVisible attribute to true on that type. 36 | 37 | [assembly: ComVisible(false)] 38 | 39 | // The following GUID is for the ID of the typelib if this project is exposed to COM 40 | 41 | [assembly: Guid("7087f372-9038-4acc-b06b-c1aeb7bd72af")] -------------------------------------------------------------------------------- /src/Microsoft.PackageManagement.MsiProvider/provider.manifest: -------------------------------------------------------------------------------- 1 |  2 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/Microsoft.PackageManagement.MsuProvider/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("MsuProvider")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("MsuProvider")] 13 | [assembly: AssemblyCopyright("Copyright © 2014")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | [assembly: AssemblyFileVersionAttribute("3.0.0.0")] 17 | [assembly: AssemblyVersion("3.0.0.0")] 18 | 19 | // Setting ComVisible to false makes the types in this assembly not visible 20 | // to COM components. If you need to access a type in this assembly from 21 | // COM, set the ComVisible attribute to true on that type. 22 | [assembly: ComVisible(false)] 23 | 24 | // The following GUID is for the ID of the typelib if this project is exposed to COM 25 | [assembly: Guid("758b6eb4-cf8d-4841-bdce-ae002bd207f8")] -------------------------------------------------------------------------------- /src/Microsoft.PackageManagement.MsuProvider/provider.manifest: -------------------------------------------------------------------------------- 1 |  2 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/Microsoft.PackageManagement/Api/ICoreApi.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | // 14 | 15 | namespace Microsoft.PackageManagement.Internal.Api { 16 | 17 | /// 18 | /// Provides access to CORE functionality to PROVIDERs as part of the current request object. 19 | /// 20 | public interface ICoreApi { 21 | /// 22 | /// Returns a reference to the PackageManagementService object. 23 | /// 24 | IPackageManagementService PackageManagementService { get; } 25 | 26 | /// Returns a reference to the Provider Services object. 27 | IProviderServices ProviderServices { get; } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/Microsoft.PackageManagement/Api/IProviderServices.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | // 14 | 15 | namespace Microsoft.PackageManagement.Internal.Api { 16 | using System; 17 | using System.Collections.Generic; 18 | using PackageManagement.Packaging; 19 | 20 | public interface IProviderServices { 21 | #region declare service-apis 22 | 23 | bool IsElevated {get;} 24 | 25 | IEnumerable FindPackageByCanonicalId(string canonicalId, IRequest requestObject); 26 | 27 | string GetCanonicalPackageId(string providerName, string packageName, string version, string source); 28 | 29 | string ParseProviderName(string canonicalPackageId); 30 | 31 | string ParsePackageName(string canonicalPackageId); 32 | 33 | string ParsePackageVersion(string canonicalPackageId); 34 | 35 | string ParsePackageSource(string canonicalPackageId); 36 | 37 | string DownloadFile(Uri remoteLocation, string localFilename, IRequest requestObject); 38 | 39 | string DownloadFile(Uri remoteLocation, string localFilename,int timeoutMilliseconds, bool showProgress, IRequest requestObject); 40 | 41 | bool IsSupportedArchive(string localFilename, IRequest requestObject); 42 | 43 | IEnumerable UnpackArchive(string localFilename, string destinationFolder, IRequest requestObject); 44 | 45 | bool Install(string fileName, string additionalArgs, IRequest requestObject); 46 | 47 | bool IsSignedAndTrusted(string filename, IRequest requestObject); 48 | 49 | int StartProcess(string filename, string arguments, bool requiresElevation, out string standardOutput, IRequest requestObject); 50 | 51 | #endregion 52 | } 53 | } -------------------------------------------------------------------------------- /src/Microsoft.PackageManagement/Api/IRequest.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | // 14 | 15 | namespace Microsoft.PackageManagement.Internal.Api { 16 | public interface IRequest : IHostApi, ICoreApi, IResponseApi { 17 | } 18 | } -------------------------------------------------------------------------------- /src/Microsoft.PackageManagement/ErrorCategory.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | // 14 | 15 | namespace Microsoft.PackageManagement.Internal { 16 | public enum ErrorCategory { 17 | NotSpecified, 18 | OpenError, 19 | CloseError, 20 | DeviceError, 21 | DeadlockDetected, 22 | InvalidArgument, 23 | InvalidData, 24 | InvalidOperation, 25 | InvalidResult, 26 | InvalidType, 27 | MetadataError, 28 | NotImplemented, 29 | NotInstalled, 30 | ObjectNotFound, 31 | OperationStopped, 32 | OperationTimeout, 33 | SyntaxError, 34 | ParserError, 35 | PermissionDenied, 36 | ResourceBusy, 37 | ResourceExists, 38 | ResourceUnavailable, 39 | ReadError, 40 | WriteError, 41 | FromStdErr, 42 | SecurityError, 43 | ProtocolError, 44 | ConnectionError, 45 | AuthenticationError, 46 | LimitsExceeded, 47 | QuotaExceeded, 48 | NotEnabled, 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/Microsoft.PackageManagement/IPackageManagementService.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | // 14 | 15 | namespace Microsoft.PackageManagement.Internal { 16 | using System; 17 | using System.Collections.Generic; 18 | using Api; 19 | using Implementation; 20 | using PackageManagement.Implementation; 21 | using PackageManagement.Packaging; 22 | 23 | /// 24 | /// The current Package Management Service Interface 25 | /// Binding directly to this is discouraged, as the interface is expected to be incrementally 26 | /// expanded over time. 27 | /// In order to access the interface, the Host (client) is encouraged to copy this interface 28 | /// into their own project and use the PackageManagementService.GetInstance]]> 29 | /// method to dynamically generate a matching implementation at load time. 30 | /// 31 | public interface IPackageManagementService { 32 | int Version {get;} 33 | 34 | IEnumerable ProviderNames {get;} 35 | 36 | IEnumerable AllProviderNames { get; } 37 | 38 | IEnumerable PackageProviders {get;} 39 | 40 | IEnumerable GetAvailableProviders(IHostApi requestObject, string[] names); 41 | 42 | IEnumerable ImportPackageProvider(IHostApi requestObject, string providerName, Version requiredVersion, 43 | Version minimumVersion, Version maximumVersion, bool isRooted, bool force); 44 | 45 | bool Initialize(IHostApi requestObject); 46 | 47 | IEnumerable SelectProvidersWithFeature(string featureName); 48 | 49 | IEnumerable SelectProvidersWithFeature(string featureName, string value); 50 | 51 | IEnumerable SelectProviders(string providerName, IHostApi requestObject); 52 | 53 | IEnumerable FindPackageByCanonicalId(string packageId, IHostApi requestObject); 54 | 55 | bool RequirePackageProvider(string requestor, string packageProviderName, string minimumVersion, IHostApi requestObject); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/Microsoft.PackageManagement/Implementation/ActionRequestObject.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | // 14 | 15 | namespace Microsoft.PackageManagement.Internal.Implementation { 16 | using System; 17 | using Internal.Api; 18 | 19 | public class ActionRequestObject : RequestObject { 20 | public ActionRequestObject(ProviderBase provider, IHostApi hostApi, Action action) : base(provider, hostApi, action) { 21 | InvokeImpl(); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/Microsoft.PackageManagement/Implementation/Archiver.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | // 14 | 15 | namespace Microsoft.PackageManagement.Internal.Implementation { 16 | using System.Collections.Generic; 17 | using Api; 18 | using Providers; 19 | 20 | internal class Archiver : ProviderBase { 21 | private string _name; 22 | 23 | internal Archiver(IArchiver provider) 24 | : base(provider) { 25 | } 26 | 27 | public override string ProviderName { 28 | get { 29 | return _name ?? (_name = Provider.GetArchiverName()); 30 | } 31 | } 32 | 33 | public override bool IsSupportedFile(string localFilename) { 34 | return base.IsSupportedFile(localFilename) && Provider.IsSupportedFile(localFilename); 35 | } 36 | 37 | public IEnumerable UnpackArchive(string localFilename, string destinationFolder, IHostApi host) { 38 | return new FuncRequestObject>(this, host, (request) => Provider.UnpackArchive(localFilename, destinationFolder, request)).Value; 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /src/Microsoft.PackageManagement/Implementation/DictionaryRequestObject.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | // 14 | 15 | namespace Microsoft.PackageManagement.Internal.Implementation { 16 | using System; 17 | using System.Collections.Generic; 18 | using Api; 19 | using Utility.Async; 20 | using Utility.Extensions; 21 | 22 | public class DictionaryRequestObject : RequestObject, IAsyncValue>> { 23 | private readonly Dictionary> _results = new Dictionary>(StringComparer.OrdinalIgnoreCase); 24 | 25 | public DictionaryRequestObject(ProviderBase provider, IHostApi request, Action action) 26 | : base(provider, request, action) { 27 | InvokeImpl(); 28 | } 29 | 30 | public Dictionary> Value { 31 | get { 32 | this.Wait(); 33 | return _results; 34 | } 35 | } 36 | 37 | public override bool YieldKeyValuePair(string key, string value) { 38 | _results.GetOrAdd(key, () => new List()).Add(value); 39 | return !IsCanceled; 40 | } 41 | } 42 | } -------------------------------------------------------------------------------- /src/Microsoft.PackageManagement/Implementation/Downloader.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | // 14 | 15 | namespace Microsoft.PackageManagement.Internal.Implementation { 16 | using System; 17 | using Api; 18 | using Providers; 19 | 20 | internal class Downloader : ProviderBase { 21 | private string _name; 22 | 23 | internal Downloader(IDownloader provider) 24 | : base(provider) { 25 | } 26 | 27 | public override string ProviderName { 28 | get { 29 | return _name ?? (_name = Provider.GetDownloaderName()); 30 | } 31 | } 32 | 33 | public string DownloadFile(Uri remoteLocation, string localFilename, int timeoutMilliseconds, bool showProgress, IHostApi requestObject) { 34 | return new FuncRequestObject(this, requestObject, request => Provider.DownloadFile(remoteLocation, localFilename,timeoutMilliseconds,showProgress, request)).Value; 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /src/Microsoft.PackageManagement/Implementation/Extensions.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | // 14 | 15 | namespace Microsoft.PackageManagement.Internal.Implementation { 16 | using System.Globalization; 17 | using Api; 18 | using Utility.Extensions; 19 | 20 | internal static class Extensions { 21 | internal static string FormatMessageString(this IHostApi request, string messageText, params object[] args) { 22 | if (string.IsNullOrWhiteSpace(messageText)) { 23 | return string.Empty; 24 | } 25 | 26 | if (messageText.IndexOf(Constants.MSGPrefix, System.StringComparison.CurrentCultureIgnoreCase) == 0) { 27 | messageText = request.GetMessageString(messageText.Substring(Constants.MSGPrefix.Length), messageText) ?? messageText; 28 | } 29 | 30 | return args == null || args.Length == 0 ? messageText : messageText.format(args); 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /src/Microsoft.PackageManagement/Implementation/FuncRequestObject.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | // 14 | 15 | namespace Microsoft.PackageManagement.Internal.Implementation { 16 | using System; 17 | using Api; 18 | using Utility.Async; 19 | 20 | public class FuncRequestObject : RequestObject, IAsyncValue { 21 | private T _result; 22 | 23 | public FuncRequestObject(ProviderBase provider, IHostApi hostApi, Func function) 24 | : base(provider, hostApi, null) { 25 | _action = r => {_result = function(r);}; 26 | InvokeImpl(); 27 | } 28 | 29 | public T Value { 30 | get { 31 | // wait for end. 32 | this.Wait(); 33 | return _result; 34 | } 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /src/Microsoft.PackageManagement/Implementation/PackageDetailsRequestObject.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | // 14 | 15 | namespace Microsoft.PackageManagement.Internal.Implementation { 16 | using System; 17 | using Api; 18 | using PackageManagement.Packaging; 19 | 20 | public class PackageDetailsRequestObject : RequestObject { 21 | private SoftwareIdentity _softwareIdentity; 22 | 23 | public PackageDetailsRequestObject(ProviderBase provider, IHostApi hostApi, SoftwareIdentity softwareIdentity, Action action) 24 | : base(provider, hostApi, action) { 25 | _softwareIdentity = softwareIdentity; 26 | InvokeImpl(); 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /src/Microsoft.PackageManagement/PackageManager.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | // 14 | 15 | namespace Microsoft.PackageManagement.Internal { 16 | using Implementation; 17 | 18 | /// 19 | /// The public interface to accessing the fetaures of the Package Management Service 20 | /// This offers two possible methods to get the instance of the PackageManagementService. 21 | /// If the Host is consuming the PackageManagementService by linking to this assembly, then 22 | /// the simplest access is just to use the Instance method. 23 | /// If the Host has dynamically loaded this assembly, then it can request a dynamically-generated 24 | /// instance of the PackageManagementService that implements an interface of their own choosing. 25 | /// 30 | /// 31 | /// 32 | internal static class PackageManager { 33 | private static readonly object _lockObject = new object(); 34 | internal static IPackageManagementService _instance; 35 | 36 | public static IPackageManagementService Instance { 37 | get { 38 | lock (_lockObject) { 39 | if (_instance == null) { 40 | _instance = new PackageManagementService(); 41 | } 42 | } 43 | return _instance; 44 | } 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/Microsoft.PackageManagement/Packaging/DynamicOption.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | // 14 | 15 | namespace Microsoft.PackageManagement.Internal.Packaging { 16 | using System.Collections.Generic; 17 | using System.Diagnostics.CodeAnalysis; 18 | using System.Linq; 19 | 20 | public class DynamicOption { 21 | private IEnumerable _values; 22 | public string ProviderName {get; set;} 23 | public OptionCategory Category {get; internal set;} 24 | public string Name {get; internal set;} 25 | [SuppressMessage("Microsoft.Naming", "CA1721:PropertyNamesShouldNotMatchGetMethods", Justification = "Type is OK for a cmdlet parameter")] 26 | public OptionType Type { get; internal set;} 27 | public bool IsRequired {get; internal set;} 28 | 29 | public IEnumerable PossibleValues { 30 | get { 31 | return _values ?? Enumerable.Empty(); 32 | } 33 | internal set { 34 | _values = value; 35 | } 36 | } 37 | } 38 | } -------------------------------------------------------------------------------- /src/Microsoft.PackageManagement/Packaging/File.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | // 14 | 15 | namespace Microsoft.PackageManagement.Internal.Packaging { 16 | using System; 17 | using System.Xml.Linq; 18 | 19 | /// 20 | /// Represents an individual file 21 | /// 22 | public class File : FilesystemItem { 23 | internal File(XElement element) 24 | : base(element) { 25 | if (element.Name != Iso19770_2.Elements.File) { 26 | throw new ArgumentException("Element is not of type 'File'", "element"); 27 | } 28 | } 29 | 30 | internal File(string filename) 31 | : base(new XElement(Iso19770_2.Elements.File)) { 32 | Name = filename; 33 | } 34 | 35 | /// 36 | /// From the swidtag schema: 37 | /// The file size in bytes of the file 38 | /// 39 | public long? Size { 40 | get { 41 | var sz = GetAttribute(Iso19770_2.Attributes.Size); 42 | if (sz != null) { 43 | long result; 44 | if (Int64.TryParse(sz, out result)) { 45 | return result; 46 | } 47 | } 48 | return null; 49 | } 50 | internal set { 51 | if (value != null) { 52 | AddAttribute(Iso19770_2.Attributes.Size, value.ToString()); 53 | } 54 | } 55 | } 56 | 57 | /// 58 | /// From the swidtag schema: 59 | /// The file version 60 | /// 61 | public string Version { 62 | get { 63 | return GetAttribute(Iso19770_2.Attributes.Version); 64 | } 65 | internal set { 66 | AddAttribute(Iso19770_2.Attributes.Version, value); 67 | } 68 | } 69 | } 70 | } -------------------------------------------------------------------------------- /src/Microsoft.PackageManagement/Packaging/Meta.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | // 14 | 15 | namespace Microsoft.PackageManagement.Internal.Packaging { 16 | using System.Xml.Linq; 17 | 18 | /// 19 | /// An intermediate base class for elements in the swidtag that support 20 | /// arbitrary attributes in the default namespace. 21 | /// From the swidtag schema: 22 | /// An open-ended collection of key/value data related to this SWID. 23 | /// Permits any user-defined attributes in Meta tags 24 | /// 25 | public class Meta : BaseElement { 26 | internal Meta(XElement element) 27 | : base(element) { 28 | // we don't do an Element type validation here, since this will get called from 29 | // child classes too. 30 | // and that's ok, because Meta doesn't directly have any predefined fields anyway. 31 | } 32 | 33 | internal Meta() 34 | : base(new XElement(Iso19770_2.Elements.Meta)) { 35 | } 36 | 37 | public string this[string key] { 38 | get { 39 | return Attributes[key]; 40 | } 41 | } 42 | 43 | public override string ToString() { 44 | return Attributes != null ? Attributes.ToString() : string.Empty; 45 | } 46 | 47 | /// 48 | /// Determines if the element contains an attribute with the given name. 49 | /// 50 | /// the attribute to find 51 | /// True, if the element contains the attribute. 52 | public bool ContainsKey(string key) { 53 | if (string.IsNullOrWhiteSpace(key)) { 54 | return false; 55 | } 56 | 57 | return Element.Attribute(key) != null; 58 | } 59 | } 60 | } -------------------------------------------------------------------------------- /src/Microsoft.PackageManagement/Packaging/OptionCategory.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | // 14 | 15 | namespace Microsoft.PackageManagement.Internal.Packaging { 16 | public enum OptionCategory { 17 | Package = 0, 18 | Provider = 1, 19 | Source = 2, 20 | Install = 3 21 | } 22 | } -------------------------------------------------------------------------------- /src/Microsoft.PackageManagement/Packaging/OptionType.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | // 14 | 15 | namespace Microsoft.PackageManagement.Internal.Packaging { 16 | public enum OptionType { 17 | String = 0, 18 | StringArray = 1, 19 | Int = 2, 20 | Switch = 3, 21 | Folder = 4, 22 | File = 5, 23 | Path = 6, 24 | Uri = 7, 25 | SecureString = 8 26 | } 27 | } -------------------------------------------------------------------------------- /src/Microsoft.PackageManagement/Packaging/PackageSource.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | // 14 | 15 | namespace Microsoft.PackageManagement.Packaging { 16 | using System; 17 | using System.Collections.Generic; 18 | using Implementation; 19 | 20 | /// 21 | /// Represents a package source (repository) 22 | /// 23 | public class PackageSource { 24 | internal Dictionary DetailsCollection = new Dictionary(); 25 | public string Name {get; internal set;} 26 | public string Location {get; internal set;} 27 | 28 | public string Source { 29 | get { 30 | return Name ?? Location; 31 | } 32 | } 33 | 34 | // todo: make this dictionary read only! (.net 4.0 doesn't have that!) 35 | 36 | public string ProviderName { 37 | get { 38 | return Provider.ProviderName; 39 | } 40 | } 41 | 42 | public PackageProvider Provider {get; internal set;} 43 | public bool IsTrusted {get; internal set;} 44 | public bool IsRegistered {get; internal set;} 45 | public bool IsValidated {get; internal set;} 46 | 47 | public IDictionary Details { 48 | get { 49 | return DetailsCollection; 50 | } 51 | } 52 | 53 | public override bool Equals(Object obj) 54 | { 55 | PackageSource packageSource = obj as PackageSource; 56 | if (packageSource == null) 57 | return false; 58 | else 59 | return ((Name.Equals(packageSource.Name) && Location.Equals(packageSource.Location))); 60 | } 61 | 62 | public override int GetHashCode() 63 | { 64 | return ((Name ?? String.Empty) + (Location ?? String.Empty)).GetHashCode(); 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /src/Microsoft.PackageManagement/Packaging/Payload.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | // 14 | 15 | namespace Microsoft.PackageManagement.Internal.Packaging { 16 | using System; 17 | using System.Xml.Linq; 18 | 19 | /// 20 | /// From the schema: 21 | /// The items that may be installed on a device when the software is 22 | /// installed. Note that Payload may be a superset of the items 23 | /// installed and, depending on optimization systems for a device, 24 | /// may or may not include every item that could be created or 25 | /// executed on a device when software is installed. 26 | /// In general, payload will be used to indicate the files that 27 | /// may be installed with a software product and will often be a 28 | /// superset of those files (i.e. if a particular optional 29 | /// component is not installed, the files associated with that 30 | /// component may be included in payload, but not installed on 31 | /// the device). 32 | /// 33 | public class Payload : ResourceCollection { 34 | internal Payload(XElement element) 35 | : base(element) { 36 | if (element.Name != Iso19770_2.Elements.Payload) { 37 | throw new ArgumentException("Element is not of type 'Payload'", "element"); 38 | } 39 | } 40 | 41 | internal Payload() 42 | : base(new XElement(Iso19770_2.Elements.Payload)) { 43 | } 44 | } 45 | } -------------------------------------------------------------------------------- /src/Microsoft.PackageManagement/Packaging/Process.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | // 14 | 15 | namespace Microsoft.PackageManagement.Internal.Packaging { 16 | using System; 17 | using System.Xml.Linq; 18 | 19 | public class Process : Meta { 20 | internal Process(XElement element) 21 | : base(element) { 22 | if (element.Name != Iso19770_2.Elements.Process) { 23 | throw new ArgumentException("Element is not of type 'Process'", "element"); 24 | } 25 | } 26 | 27 | internal Process(string processName) 28 | : base(new XElement(Iso19770_2.Elements.Process)) { 29 | Name = processName; 30 | } 31 | 32 | /// 33 | /// From the swidtag schema: 34 | /// The process name as it will be found in the devices process table. 35 | /// 36 | public string Name { 37 | get { 38 | return GetAttribute(Iso19770_2.Attributes.Name); 39 | } 40 | internal set { 41 | AddAttribute(Iso19770_2.Attributes.Name, value); 42 | } 43 | } 44 | 45 | /// 46 | /// From the swidtag schema: 47 | /// The file size in bytes of the file 48 | /// 49 | public int? Pid { 50 | get { 51 | var sz = GetAttribute(Iso19770_2.Attributes.Size); 52 | if (sz != null) { 53 | int result; 54 | if (Int32.TryParse(sz, out result)) { 55 | return result; 56 | } 57 | } 58 | return null; 59 | } 60 | internal set { 61 | if (value != null) { 62 | AddAttribute(Iso19770_2.Attributes.Pid, value.ToString()); 63 | } 64 | } 65 | } 66 | } 67 | } -------------------------------------------------------------------------------- /src/Microsoft.PackageManagement/Packaging/Resource.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | // 14 | 15 | namespace Microsoft.PackageManagement.Internal.Packaging { 16 | using System; 17 | using System.Diagnostics.CodeAnalysis; 18 | using System.Xml.Linq; 19 | 20 | /// 21 | /// Specifies an arbitrary or custom resource in a swidtag. 22 | /// From the swidtag schema: 23 | /// A element that can be used to provide arbitrary resource 24 | /// information about an application installed on a device, or 25 | /// evidence collected from a device. 26 | /// 27 | public class Resource : Meta { 28 | internal Resource(XElement element) 29 | : base(element) { 30 | if (element.Name != Iso19770_2.Elements.Resource) { 31 | throw new ArgumentException("Element is not of type 'Resource'", "element"); 32 | } 33 | } 34 | 35 | internal Resource(string type) 36 | : base(new XElement(Iso19770_2.Elements.Resource)) { 37 | Type = type; 38 | } 39 | 40 | /// 41 | /// Specifies the what type of a resource is being recorded. 42 | /// From the swidtag schema: 43 | /// The type of resource (ie, registrykey, port, rootUrl,etc..) 44 | /// 45 | [SuppressMessage("Microsoft.Naming", "CA1721:PropertyNamesShouldNotMatchGetMethod", Justification = "ISO field name.")] 46 | public string Type { 47 | get { 48 | return GetAttribute(Iso19770_2.Attributes.Type); 49 | } 50 | internal set { 51 | AddAttribute(Iso19770_2.Attributes.Type, value); 52 | } 53 | } 54 | } 55 | } -------------------------------------------------------------------------------- /src/Microsoft.PackageManagement/Packaging/SoftwareIdentityNameVersionComparer.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | // 14 | 15 | using System; 16 | using System.Collections.Generic; 17 | using Microsoft.PackageManagement.Internal.Utility.Extensions; 18 | using Microsoft.PackageManagement.Packaging; 19 | 20 | namespace Microsoft.PackageManagement.Internal.Packaging 21 | { 22 | /// 23 | /// 2 Swids will be equal if their names and versions are the same 24 | /// 25 | public class SoftwareIdentityNameVersionComparer : IEqualityComparer 26 | { 27 | private static SoftwareIdentityVersionComparer VersionComparer = new SoftwareIdentityVersionComparer(); 28 | 29 | public bool Equals(SoftwareIdentity swidOne, SoftwareIdentity swidTwo) 30 | { 31 | // True if both are null 32 | if (swidOne == null && swidTwo == null) 33 | { 34 | return true; 35 | } 36 | 37 | // False if 1 is null and the other is not 38 | if (swidOne == null || swidTwo == null) 39 | { 40 | return false; 41 | } 42 | 43 | // true if name is same and version is same 44 | return String.Equals(swidOne.Name, swidTwo.Name, StringComparison.OrdinalIgnoreCase) && (VersionComparer.Compare(swidOne, swidTwo) == 0); 45 | } 46 | 47 | public int GetHashCode(SoftwareIdentity obj) 48 | { 49 | if (obj == null) 50 | { 51 | return 0; 52 | } 53 | 54 | return (String.IsNullOrWhiteSpace(obj.Name) ? String.Empty : obj.Name).GetHashCode() * 31 55 | + (String.IsNullOrWhiteSpace(obj.Version) ? String.Empty : obj.Version).GetHashCode(); 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/Microsoft.PackageManagement/Utility/Async/IAsyncAction.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | // 14 | 15 | namespace Microsoft.PackageManagement.Internal.Utility.Async { 16 | using System; 17 | using System.Threading; 18 | 19 | public interface IAsyncAction : IDisposable { 20 | WaitHandle CompleteEvent {get;} 21 | TimeSpan Timeout {get; set;} 22 | TimeSpan Responsiveness {get; set;} 23 | bool IsCanceled {get;} 24 | bool IsAborted {get;} 25 | bool IsCompleted {get;} 26 | void Cancel(); 27 | void Abort(); 28 | event Action OnComplete; 29 | event Action OnCancel; 30 | event Action OnAbort; 31 | } 32 | } -------------------------------------------------------------------------------- /src/Microsoft.PackageManagement/Utility/Async/IAsyncEnumerable.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | // 14 | 15 | namespace Microsoft.PackageManagement.Internal.Utility.Async { 16 | using System.Collections.Generic; 17 | using System.Threading; 18 | 19 | public interface IAsyncEnumerable : IAsyncAction, IEnumerable { 20 | bool IsConsumed {get;} 21 | bool HasData {get;} 22 | WaitHandle Ready {get;} 23 | IEnumerable GetConsumingEnumerable(); 24 | IEnumerable GetBlockingEnumerable(); 25 | } 26 | } -------------------------------------------------------------------------------- /src/Microsoft.PackageManagement/Utility/Async/IAsyncValue.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | // 14 | 15 | namespace Microsoft.PackageManagement.Internal.Utility.Async { 16 | public interface IAsyncValue : IAsyncAction { 17 | T Value {get;} 18 | } 19 | } -------------------------------------------------------------------------------- /src/Microsoft.PackageManagement/Utility/Collections/CancellableEnumerator.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | // 14 | 15 | namespace Microsoft.PackageManagement.Internal.Utility.Collections { 16 | using System; 17 | using System.Collections; 18 | using System.Collections.Generic; 19 | using System.Threading; 20 | 21 | internal class CancellableEnumerator : IEnumerator, ICancellableEnumerator { 22 | private IEnumerator _enumerator; 23 | private readonly CancellationTokenSource _cancellationTokenSource; 24 | 25 | public CancellableEnumerator(CancellationTokenSource cts, IEnumerator enumerator) { 26 | _enumerator = enumerator; 27 | _cancellationTokenSource = cts; 28 | } 29 | 30 | public void Cancel() { 31 | _cancellationTokenSource.Cancel(); 32 | } 33 | 34 | public bool MoveNext() { 35 | // if the collection has been cancelled, then don't advance anymore. 36 | return !_cancellationTokenSource.IsCancellationRequested && _enumerator.MoveNext(); 37 | } 38 | 39 | public void Dispose() { 40 | Dispose(true); 41 | GC.SuppressFinalize(this); 42 | } 43 | 44 | public void Reset() { 45 | _enumerator.Reset(); 46 | } 47 | 48 | public T Current { 49 | get { 50 | return (T)_enumerator.Current; 51 | } 52 | } 53 | 54 | object IEnumerator.Current { 55 | get { 56 | return _enumerator.Current; 57 | } 58 | } 59 | 60 | protected virtual void Dispose(bool disposing) { 61 | if (disposing) { 62 | if (_enumerator is IDisposable) { 63 | (_enumerator as IDisposable).Dispose(); 64 | } 65 | _enumerator = null; 66 | } 67 | } 68 | } 69 | } -------------------------------------------------------------------------------- /src/Microsoft.PackageManagement/Utility/Collections/EnumerableExtensions.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | // 14 | 15 | namespace Microsoft.PackageManagement.Internal.Utility.Collections { 16 | using System; 17 | using System.Collections.Generic; 18 | using System.Linq; 19 | 20 | internal static class EnumerableExtensions { 21 | /// 22 | /// Returns a ReEnumerable wrapper around the collection which timidly (cautiously) pulls items 23 | /// but still allows you to to re-enumerate without re-running the query. 24 | /// 25 | /// 26 | /// 27 | /// 28 | public static MutableEnumerable ReEnumerable(this IEnumerable collection) { 29 | if (collection == null) { 30 | return new ReEnumerable(Enumerable.Empty()); 31 | } 32 | return collection as MutableEnumerable ?? new ReEnumerable(collection); 33 | } 34 | 35 | public static IEnumerable FilterWithFinalizer(this IEnumerable source, Func predicate, Action onFilterAction) { 36 | foreach (var i in source) { 37 | if (predicate(i)) { 38 | onFilterAction(i); 39 | } else { 40 | yield return i; 41 | } 42 | } 43 | } 44 | } 45 | } -------------------------------------------------------------------------------- /src/Microsoft.PackageManagement/Utility/Collections/FilenameEqualityComparer.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | // 14 | 15 | namespace Microsoft.PackageManagement.Internal.Utility.Collections { 16 | internal enum PathCompareOption { 17 | Full, 18 | File, 19 | FileWithoutExtension, 20 | Extension, 21 | Nuget 22 | } 23 | } -------------------------------------------------------------------------------- /src/Microsoft.PackageManagement/Utility/Collections/ICancellableEnumerator.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | // 14 | 15 | namespace Microsoft.PackageManagement.Internal.Utility.Collections { 16 | using System.Collections.Generic; 17 | 18 | internal interface ICancellableEnumerator : IEnumerator { 19 | void Cancel(); 20 | } 21 | } -------------------------------------------------------------------------------- /src/Microsoft.PackageManagement/Utility/Collections/ReEnumerable.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | // 14 | 15 | namespace Microsoft.PackageManagement.Internal.Utility.Collections { 16 | using System.Collections.Generic; 17 | using System.Linq; 18 | 19 | internal class ReEnumerable : MutableEnumerable { 20 | private IEnumerator _sourceIterator; 21 | private readonly IEnumerable _source; 22 | 23 | public ReEnumerable(IEnumerable source) { 24 | _source = source ?? new T[0]; 25 | } 26 | 27 | public ReEnumerable(IEnumerator sourceIterator) { 28 | _source = null; 29 | _sourceIterator = sourceIterator; 30 | } 31 | 32 | public T this[int index] { 33 | get { 34 | if (ItemExists(index)) { 35 | return List[index]; 36 | } 37 | return default(T); 38 | } 39 | } 40 | 41 | public int Count { 42 | get { 43 | return this.Count(); 44 | } 45 | } 46 | 47 | protected override bool ItemExists(int index) { 48 | if (index < List.Count) { 49 | return true; 50 | } 51 | 52 | lock (this) { 53 | if (_sourceIterator == null) { 54 | _sourceIterator = _source.GetEnumerator(); 55 | } 56 | 57 | try { 58 | while (_sourceIterator.MoveNext()) { 59 | List.Add(_sourceIterator.Current); 60 | if (index < List.Count) { 61 | return true; 62 | } 63 | } 64 | } catch { 65 | // if the _sourceIterator is cancelled 66 | // then MoveNext() will throw; that's ok 67 | // that just means we're done 68 | } 69 | } 70 | return false; 71 | } 72 | 73 | public MutableEnumerable Concat(IEnumerable additionalItems) { 74 | return Enumerable.Concat(this, additionalItems).ReEnumerable(); 75 | } 76 | } 77 | } -------------------------------------------------------------------------------- /src/Microsoft.PackageManagement/Utility/Extensions/EqualityComparer.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | // 14 | 15 | namespace Microsoft.PackageManagement.Internal.Utility.Extensions { 16 | using System; 17 | using System.Collections.Generic; 18 | 19 | internal class EqualityComparer : IEqualityComparer { 20 | private readonly Func _compareFn; 21 | private readonly Func _hashFn; 22 | 23 | public EqualityComparer(Func compareFn, Func hashFn) { 24 | _compareFn = compareFn; 25 | _hashFn = hashFn; 26 | } 27 | 28 | public EqualityComparer(Func compareFn) { 29 | _compareFn = compareFn; 30 | _hashFn = (obj) =>obj.GetHashCode(); 31 | } 32 | 33 | public bool Equals(T x, T y) { 34 | return _compareFn(x, y); 35 | } 36 | 37 | public int GetHashCode(T obj) { 38 | return _hashFn(obj); 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /src/Microsoft.PackageManagement/Utility/Extensions/ExceptionExtensions.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | // 14 | 15 | namespace Microsoft.PackageManagement.Internal.Utility.Extensions { 16 | using System; 17 | using System.Globalization; 18 | using Platform; 19 | 20 | internal static class ExceptionExtensions { 21 | public static void Dump(this Exception e) { 22 | #if !CORECLR 23 | var text = string.Format(CultureInfo.CurrentCulture, "{0}/{1}\r\n{2}", e.GetType().Name, e.Message, e.StackTrace); 24 | // for now, this is the only way we'll see exceptions in the wild. 25 | NativeMethods.OutputDebugString(text); 26 | #endif 27 | } 28 | 29 | public static void Dump(this Exception e, Microsoft.PackageManagement.Internal.Api.IHostApi request) 30 | { 31 | System.Diagnostics.Debug.Assert(request != null, "request cannot be null"); 32 | 33 | if (request != null) { 34 | request.Debug(string.Format(CultureInfo.CurrentCulture, "{0}\r\n{1}", e.Message, e.StackTrace)); 35 | 36 | if(e.InnerException != null) { 37 | request.Debug(string.Format(CultureInfo.CurrentCulture, "{0}\r\n{1}", e.InnerException.Message, e.InnerException.StackTrace)); 38 | } 39 | } 40 | } 41 | 42 | #if DETAILED_DEBUG 43 | private static DateTime startTime = DateTime.Now; 44 | public static T DumpTime(this T nothing) { 45 | StackTrace s = new StackTrace(true); 46 | var f = s.GetFrame(1); 47 | 48 | Console.WriteLine(" OFFSET: \r\n {0}:{1}:\r\n {2}\r\n Time:[{3}] ",f.GetFileName(), f.GetFileLineNumber(), f.GetMethod(), DateTime.Now.Subtract(startTime).TotalMilliseconds); 49 | return nothing; 50 | } 51 | #endif 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/Microsoft.PackageManagement/Utility/Extensions/TaskExtensions.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | // 14 | 15 | namespace Microsoft.PackageManagement.Internal.Utility.Extensions { 16 | using System.Diagnostics.CodeAnalysis; 17 | using System.Threading.Tasks; 18 | 19 | internal static class TaskExtensions { 20 | public static Task AsResultTask(this T result) { 21 | var x = new TaskCompletionSource(TaskCreationOptions.AttachedToParent); 22 | x.SetResult(result); 23 | return x.Task; 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /src/Microsoft.PackageManagement/Utility/Extensions/ThreadPerTaskScheduler.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | // 14 | 15 | namespace Microsoft.PackageManagement.Internal.Utility.Extensions { 16 | using System.Collections.Generic; 17 | using System.Linq; 18 | using System.Threading; 19 | using System.Threading.Tasks; 20 | 21 | internal class ThreadPerTaskScheduler : TaskScheduler { 22 | /// Gets the tasks currently scheduled to this scheduler. 23 | /// This will always return an empty enumerable, as tasks are launched as soon as they're queued. 24 | protected override IEnumerable GetScheduledTasks() { 25 | return Enumerable.Empty(); 26 | } 27 | 28 | /// Starts a new thread to process the provided task. 29 | /// The task to be executed. 30 | protected override void QueueTask(Task task) { 31 | new Thread(() => TryExecuteTask(task)) { 32 | IsBackground = true 33 | }.Start(); 34 | } 35 | 36 | /// Runs the provided task on the current thread. 37 | /// The task to be executed. 38 | /// Ignored. 39 | /// Whether the task could be executed on the current thread. 40 | protected override bool TryExecuteTaskInline(Task task, bool taskWasPreviouslyQueued) { 41 | return TryExecuteTask(task); 42 | } 43 | } 44 | } -------------------------------------------------------------------------------- /src/Microsoft.PackageManagement/Utility/Extensions/Types.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | // 14 | 15 | namespace Microsoft.PackageManagement.Internal.Utility.Extensions { 16 | using System; 17 | using System.Linq; 18 | 19 | internal class Types { 20 | private readonly Type _first; 21 | private readonly Type[] _second; 22 | 23 | public Types(Type first, params Type[] second) { 24 | _first = first; 25 | _second = second; 26 | } 27 | 28 | public override int GetHashCode() { 29 | return _second.Aggregate(_first.FullName.GetHashCode(), (current, each) => current ^ each.GetHashCode()); 30 | } 31 | 32 | public override bool Equals(object obj) { 33 | if (obj == this) { 34 | return true; 35 | } 36 | var other = obj as Types; 37 | return other != null && (_first == other._first && _second.SequenceEqual(other._second)); 38 | } 39 | } 40 | } -------------------------------------------------------------------------------- /src/Microsoft.PackageManagement/Utility/Platform/AdminPrivilege.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | // 14 | 15 | namespace Microsoft.PackageManagement.Internal.Utility.Platform { 16 | using System.Security.Principal; 17 | 18 | internal class AdminPrivilege { 19 | /// 20 | /// The function checks whether the current process is run as administrator. In other words, it dictates whether the 21 | /// primary access token of the process belongs to user account that is a member of the local Administrators group and 22 | /// it is elevated. 23 | /// 24 | /// 25 | /// Returns true if the primary access token of the process belongs to user account that is a member of the local 26 | /// Administrators group and it is elevated. Returns false if the token does not. 27 | /// 28 | public static bool IsElevated { 29 | get 30 | { 31 | if (!OSInformation.IsWindows) 32 | { 33 | //it is not possible to detect whether a user is an admin/sudo or not on Linux 34 | //try out first and will log error later. 35 | return true; 36 | //return OSInformation.IsSudoUser; 37 | } 38 | else 39 | { 40 | var id = WindowsIdentity.GetCurrent(); 41 | var principal = new WindowsPrincipal(id); 42 | return principal.IsInRole(WindowsBuiltInRole.Administrator); 43 | } 44 | } 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/Microsoft.PackageManagement/Utility/Platform/WinTrustData.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | // 14 | 15 | namespace Microsoft.PackageManagement.Internal.Utility.Platform { 16 | using System; 17 | using System.Runtime.InteropServices; 18 | 19 | [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] 20 | internal class WinTrustData 21 | { 22 | #if !CORECLR 23 | private UInt32 StructSize = (UInt32)Marshal.SizeOf(typeof(WinTrustData)); 24 | #else 25 | private UInt32 StructSize = (UInt32)Marshal.SizeOf(); 26 | #endif 27 | private IntPtr PolicyCallbackData = IntPtr.Zero; 28 | private IntPtr SIPClientData = IntPtr.Zero; 29 | private uint UIChoice = 2; 30 | private uint RevocationChecks = 0; 31 | private uint UnionChoice = 1; 32 | private IntPtr FileInfoPtr; 33 | private uint StateAction = 0; 34 | private IntPtr StateData = IntPtr.Zero; 35 | private String URLReference; 36 | private uint ProvFlags = 0x00000040; // check revocation chain. 37 | private uint UIContext = 0; 38 | 39 | // constructor for silent WinTrustDataChoice.File check 40 | public WinTrustData(String filename) { 41 | var wtfiData = new WinTrustFileInfo(filename); 42 | #if !CORECLR 43 | FileInfoPtr = Marshal.AllocCoTaskMem(Marshal.SizeOf(typeof(WinTrustFileInfo))); 44 | #else 45 | FileInfoPtr = Marshal.AllocCoTaskMem(Marshal.SizeOf()); 46 | #endif 47 | Marshal.StructureToPtr(wtfiData, FileInfoPtr, false); 48 | } 49 | 50 | ~WinTrustData() { 51 | Marshal.FreeCoTaskMem(FileInfoPtr); 52 | } 53 | } 54 | } -------------------------------------------------------------------------------- /src/Microsoft.PackageManagement/Utility/Platform/WinTrustFileInfo.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | // 14 | 15 | namespace Microsoft.PackageManagement.Internal.Utility.Platform { 16 | using System; 17 | using System.Runtime.InteropServices; 18 | 19 | [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] 20 | internal class WinTrustFileInfo { 21 | #if !CORECLR 22 | private UInt32 StructSize = (UInt32)Marshal.SizeOf(typeof(WinTrustFileInfo)); 23 | #else 24 | private UInt32 StructSize = (UInt32)Marshal.SizeOf(); 25 | #endif 26 | private IntPtr FilePath; // required, file name to be verified 27 | private IntPtr hFile = IntPtr.Zero; // optional, open handle to FilePath 28 | private IntPtr pgKnownSubject = IntPtr.Zero; // optional, subject type if it is known 29 | 30 | public WinTrustFileInfo(String filePath) { 31 | #if CORECLR 32 | FilePath = Marshal.StringToCoTaskMemUni(filePath); 33 | #else 34 | FilePath = Marshal.StringToCoTaskMemAuto(filePath); 35 | #endif 36 | } 37 | 38 | ~WinTrustFileInfo() { 39 | Marshal.FreeCoTaskMem(FilePath); 40 | } 41 | } 42 | } -------------------------------------------------------------------------------- /src/Microsoft.PackageManagement/Utility/Plugin/AssignableTypeComparer.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | // 14 | 15 | namespace Microsoft.PackageManagement.Internal.Utility.Plugin { 16 | using System; 17 | using System.Reflection; 18 | using System.Collections.Generic; 19 | using Extensions; 20 | 21 | internal class AssignableTypeComparer : IEqualityComparer { 22 | public static readonly AssignableTypeComparer Instance = new AssignableTypeComparer(); 23 | 24 | public bool Equals(Type x, Type y) { 25 | return IsAssignableOrCompatible(x, y); 26 | } 27 | 28 | public int GetHashCode(Type obj) { 29 | // unused. 30 | return -1; 31 | } 32 | 33 | public static bool IsAssignableOrCompatible(Type x, Type y) { 34 | if (x == null) { 35 | return y == null; 36 | } 37 | 38 | return x == y || x.GetTypeInfo().IsAssignableFrom(y.GetTypeInfo()) || x.CanDynamicCastFrom(y); 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /src/Microsoft.PackageManagement/Utility/Plugin/RequiredAttribute.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | // 14 | 15 | namespace Microsoft.PackageManagement.Internal.Utility.Plugin { 16 | using System; 17 | 18 | internal class RequiredAttribute : Attribute { 19 | } 20 | } -------------------------------------------------------------------------------- /src/Microsoft.PackageManagement/providers/IArchiver.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | // 14 | 15 | namespace Microsoft.PackageManagement.Internal.Providers { 16 | using System.Collections.Generic; 17 | using PackageManagement.Internal.Api; 18 | using PackageManagement.Internal.Utility.Plugin; 19 | 20 | public interface IArchiver : IProvider { 21 | /// 22 | /// Returns the name of the Provider. 23 | /// 24 | /// 25 | [Required] 26 | string GetArchiverName(); 27 | 28 | [Required] 29 | IEnumerable UnpackArchive(string localFilename, string destinationFolder, IHostApi requestObject); 30 | 31 | bool IsSupportedFile(string localFilename); 32 | } 33 | } -------------------------------------------------------------------------------- /src/Microsoft.PackageManagement/providers/IDownloader.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | // 14 | 15 | namespace Microsoft.PackageManagement.Internal.Providers { 16 | using System; 17 | using PackageManagement.Internal.Api; 18 | using PackageManagement.Internal.Utility.Plugin; 19 | 20 | public interface IDownloader : IProvider { 21 | /// 22 | /// Returns the name of the Provider. 23 | /// 24 | /// 25 | [Required] 26 | string GetDownloaderName(); 27 | 28 | [Required] 29 | string DownloadFile(Uri remoteLocation, string localFilename, int timeoutMilliseconds, bool showProgress, IHostApi requestObject); 30 | } 31 | } -------------------------------------------------------------------------------- /src/Microsoft.PackageManagement/providers/inbox/Common/Extensions/EnumerableExtensions.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | // 14 | 15 | namespace Microsoft.PackageManagement.Provider.Utility { 16 | using System; 17 | using System.Collections.Generic; 18 | using System.Linq; 19 | 20 | internal static class EnumerableExtensions { 21 | /// 22 | /// Returns a ReEnumerable wrapper around the collection which timidly (cautiously) pulls items 23 | /// but still allows you to to re-enumerate without re-running the query. 24 | /// 25 | /// 26 | /// 27 | /// 28 | public static MutableEnumerable ReEnumerable(this IEnumerable collection) { 29 | if (collection == null) { 30 | return new ReEnumerable(Enumerable.Empty()); 31 | } 32 | return collection as MutableEnumerable ?? new ReEnumerable(collection); 33 | } 34 | 35 | public static IEnumerable FilterWithFinalizer(this IEnumerable source, Func predicate, Action onFilterAction) { 36 | foreach (var i in source) { 37 | if (predicate(i)) { 38 | onFilterAction(i); 39 | } else { 40 | yield return i; 41 | } 42 | } 43 | } 44 | } 45 | } -------------------------------------------------------------------------------- /src/Microsoft.PackageManagement/providers/inbox/Common/Extensions/EqualityComparer.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | // 14 | 15 | namespace Microsoft.PackageManagement.Provider.Utility { 16 | using System; 17 | using System.Collections.Generic; 18 | 19 | internal class EqualityComparer : IEqualityComparer { 20 | private readonly Func _compareFn; 21 | private readonly Func _hashFn; 22 | 23 | public EqualityComparer(Func compareFn, Func hashFn) { 24 | _compareFn = compareFn; 25 | _hashFn = hashFn; 26 | } 27 | 28 | public EqualityComparer(Func compareFn) { 29 | _compareFn = compareFn; 30 | _hashFn = (obj) =>obj.GetHashCode(); 31 | } 32 | 33 | public bool Equals(T x, T y) { 34 | return _compareFn(x, y); 35 | } 36 | 37 | public int GetHashCode(T obj) { 38 | return _hashFn(obj); 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /src/Microsoft.PackageManagement/providers/inbox/Common/Extensions/ReEnumerable.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | // 14 | 15 | namespace Microsoft.PackageManagement.Provider.Utility { 16 | using System.Collections.Generic; 17 | using System.Linq; 18 | 19 | internal class ReEnumerable : MutableEnumerable { 20 | private IEnumerator _sourceIterator; 21 | private readonly IEnumerable _source; 22 | 23 | public ReEnumerable(IEnumerable source) { 24 | _source = source ?? new T[0]; 25 | } 26 | 27 | public ReEnumerable(IEnumerator sourceIterator) { 28 | _source = null; 29 | _sourceIterator = sourceIterator; 30 | } 31 | 32 | public T this[int index] { 33 | get { 34 | if (ItemExists(index)) { 35 | return List[index]; 36 | } 37 | return default(T); 38 | } 39 | } 40 | 41 | public int Count { 42 | get { 43 | return this.Count(); 44 | } 45 | } 46 | 47 | protected override bool ItemExists(int index) { 48 | if (index < List.Count) { 49 | return true; 50 | } 51 | 52 | lock (this) { 53 | if (_sourceIterator == null) { 54 | _sourceIterator = _source.GetEnumerator(); 55 | } 56 | 57 | try { 58 | while (_sourceIterator.MoveNext()) { 59 | List.Add(_sourceIterator.Current); 60 | if (index < List.Count) { 61 | return true; 62 | } 63 | } 64 | } catch { 65 | // if the _sourceIterator is cancelled 66 | // then MoveNext() will throw; that's ok 67 | // that just means we're done 68 | } 69 | } 70 | return false; 71 | } 72 | 73 | public MutableEnumerable Concat(IEnumerable additionalItems) { 74 | return Enumerable.Concat(this, additionalItems).ReEnumerable(); 75 | } 76 | } 77 | } -------------------------------------------------------------------------------- /src/Microsoft.PackageManagement/providers/inbox/Common/Utility/XmlUtility.cs: -------------------------------------------------------------------------------- 1 | namespace Microsoft.PackageManagement.Provider.Utility 2 | { 3 | using System.IO; 4 | using System.Xml; 5 | using System.Xml.Linq; 6 | 7 | public static class XmlUtility 8 | { 9 | public static XDocument LoadSafe(string filePath) 10 | { 11 | var settings = CreateSafeSettings(); 12 | using (var reader = XmlReader.Create(filePath, settings)) 13 | { 14 | return XDocument.Load(reader); 15 | } 16 | } 17 | 18 | public static XDocument LoadSafe(Stream input, bool ignoreWhiteSpace) 19 | { 20 | var settings = CreateSafeSettings(ignoreWhiteSpace); 21 | var reader = XmlReader.Create(input, settings); 22 | return XDocument.Load(reader); 23 | } 24 | 25 | private static XmlReaderSettings CreateSafeSettings(bool ignoreWhiteSpace = false) 26 | { 27 | var safeSettings = new XmlReaderSettings 28 | { 29 | DtdProcessing = DtdProcessing.Prohibit, 30 | IgnoreWhitespace = ignoreWhiteSpace 31 | }; 32 | 33 | return safeSettings; 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/Microsoft.PackageManagement/providers/inbox/Common/Version/SemanticVersionTypeConverter.cs: -------------------------------------------------------------------------------- 1 |  2 | namespace Microsoft.PackageManagement.Provider.Utility 3 | { 4 | using System; 5 | using System.ComponentModel; 6 | using System.Globalization; 7 | 8 | /// 9 | /// Convert String to SemanticVersion type 10 | /// 11 | public class SemanticVersionTypeConverter : TypeConverter 12 | { 13 | public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) 14 | { 15 | return sourceType == typeof(string); 16 | } 17 | 18 | public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) 19 | { 20 | var stringValue = value as string; 21 | SemanticVersion semVer; 22 | if (stringValue != null && SemanticVersion.TryParse(stringValue, out semVer)) 23 | { 24 | return semVer; 25 | } 26 | return null; 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/Microsoft.PowerShell.PackageManagement/Cmdlets/AsyncCmdlet.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OneGet/oneget/d25ee92d7b3195c0bcf6f0a6162bd928418f20f6/src/Microsoft.PowerShell.PackageManagement/Cmdlets/AsyncCmdlet.cs -------------------------------------------------------------------------------- /src/Microsoft.PowerShell.PackageManagement/Cmdlets/CmdletWithProvider.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OneGet/oneget/d25ee92d7b3195c0bcf6f0a6162bd928418f20f6/src/Microsoft.PowerShell.PackageManagement/Cmdlets/CmdletWithProvider.cs -------------------------------------------------------------------------------- /src/Microsoft.PowerShell.PackageManagement/Cmdlets/CmdletWithSearch.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | // 14 | 15 | namespace Microsoft.PowerShell.PackageManagement.Cmdlets { 16 | using System.Collections.Generic; 17 | using System.Diagnostics.CodeAnalysis; 18 | using System.Management.Automation; 19 | using Microsoft.PackageManagement.Internal.Packaging; 20 | 21 | public abstract class CmdletWithSearch : CmdletWithProvider { 22 | protected CmdletWithSearch(OptionCategory[] categories) 23 | : base(categories) { 24 | } 25 | 26 | protected override IEnumerable ParameterSets { 27 | get { 28 | return new[] {""}; 29 | } 30 | } 31 | 32 | [SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")] 33 | [Parameter(Position = 0)] 34 | public virtual string[] Name {get; set;} 35 | 36 | [Parameter] 37 | public virtual string RequiredVersion {get; set;} 38 | 39 | [Parameter] 40 | public virtual string MinimumVersion {get; set;} 41 | 42 | [Parameter] 43 | public virtual string MaximumVersion {get; set;} 44 | 45 | [Parameter] 46 | public virtual SwitchParameter AllVersions { get; set; } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/Microsoft.PowerShell.PackageManagement/Cmdlets/CmdletWithSource.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | // 14 | 15 | namespace Microsoft.PowerShell.PackageManagement.Cmdlets { 16 | using System.Diagnostics.CodeAnalysis; 17 | using System.Management.Automation; 18 | using System.Security; 19 | using Microsoft.PackageManagement.Internal.Packaging; 20 | using Microsoft.PackageManagement.Packaging; 21 | 22 | public abstract class CmdletWithSource : CmdletWithProvider { 23 | protected CmdletWithSource(OptionCategory[] categories) 24 | : base(categories) { 25 | } 26 | 27 | [SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")] 28 | [Parameter(ParameterSetName = Constants.ParameterSets.SourceByInputObjectSet, Mandatory = true, ValueFromPipeline = true)] 29 | public PackageSource[] InputObject {get; set;} 30 | 31 | [Parameter] 32 | public PSCredential Credential {get; set;} 33 | 34 | public override string CredentialUsername { 35 | get { 36 | return Credential != null ? Credential.UserName : null; 37 | } 38 | } 39 | 40 | public override SecureString CredentialPassword { 41 | get { 42 | return Credential != null ? Credential.Password : null; 43 | } 44 | } 45 | 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/Microsoft.PowerShell.PackageManagement/Cmdlets/InstallPackage.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OneGet/oneget/d25ee92d7b3195c0bcf6f0a6162bd928418f20f6/src/Microsoft.PowerShell.PackageManagement/Cmdlets/InstallPackage.cs -------------------------------------------------------------------------------- /src/Microsoft.PowerShell.PackageManagement/Cmdlets/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | // 14 | 15 | using System.Reflection; 16 | using System.Runtime.CompilerServices; 17 | using System.Runtime.InteropServices; 18 | 19 | // General Information about an assembly is controlled through the following 20 | // set of attributes. Change these attribute values to modify the information 21 | // associated with an assembly. 22 | 23 | [assembly: AssemblyTitle("PackageManagement")] 24 | [assembly: AssemblyDescription("PackageManagement PowerShell Module Implementation")] 25 | [assembly: AssemblyConfiguration("")] 26 | [assembly: AssemblyCompany("Microsoft")] 27 | [assembly: AssemblyProduct("PackageManagement")] 28 | [assembly: AssemblyCopyright("Copyright © Microsoft 2014")] 29 | [assembly: AssemblyTrademark("")] 30 | [assembly: AssemblyCulture("")] 31 | 32 | // Normally, we wouldn't actaully permit access to the internals of the PackageManagement module 33 | // but we're sharing code with the other our tightly-coupled Chocolatey PowerShell module 34 | 35 | [assembly: InternalsVisibleTo(@"Microsoft.PackageManagement.Test" + @",PublicKey=0024000004800000940000000602000000240000525341310004000001000100b5fc90e7027f67871e773a8fde8938c81dd402ba65b9201d60593e96c492651e889cc13f1415ebb53fac1131ae0bd333c5ee6021672d9718ea31a8aebd0da0072f25d87dba6fc90ffd598ed4da35e44c398c454307e8e33b8426143daec9f596836f97c8f74750e5975c64e2189f45def46b2a2b1247adc3652bf5c308055da9")] 36 | 37 | // Setting ComVisible to false makes the types in this assembly not visible 38 | // to COM components. If you need to access a type in this assembly from 39 | // COM, set the ComVisible attribute to true on that type. 40 | 41 | [assembly: ComVisible(false)] 42 | 43 | // The following GUID is for the ID of the typelib if this project is exposed to COM 44 | 45 | [assembly: Guid("cef75504-d220-4860-b2df-4863f1d5c2ec")] 46 | -------------------------------------------------------------------------------- /src/Microsoft.PowerShell.PackageManagement/PackageManagement.Resources.psd1: -------------------------------------------------------------------------------- 1 | ######################################################################################### 2 | # 3 | # Copyright (c) Microsoft Corporation. All rights reserved. 4 | # 5 | # Localized PackageManagement.Resources.psd1 6 | # 7 | ######################################################################################### 8 | 9 | ConvertFrom-StringData @' 10 | ###PSLOC 11 | 12 | OldPowerShellCoreVersion=PackageManagement no longer supports PowerShell Core '{0}'. Please install the latest version of PowerShell Core from 'https://aka.ms/i6t6o3' and try again. 13 | ###PSLOC 14 | '@ -------------------------------------------------------------------------------- /src/Microsoft.PowerShell.PackageManagement/PackageManagement.psm1: -------------------------------------------------------------------------------- 1 | # 2 | # Script module for module 'PackageManagement' 3 | # 4 | Set-StrictMode -Version Latest 5 | Microsoft.PowerShell.Utility\Import-LocalizedData LocalizedData -filename PackageManagement.Resources.psd1 6 | 7 | # Summary: PackageManagement is supported on Windows PowerShell 3.0 or later, Nano Server and PowerShellCore 8 | $binarySubPath = 'fullclr' 9 | 10 | # Set up some helper variables to make it easier to work with the module 11 | $script:PSModule = $ExecutionContext.SessionState.Module 12 | $script:PSModuleRoot = $script:PSModule.ModuleBase 13 | 14 | $script:PkgMgmt = 'Microsoft.PackageManagement.dll' 15 | $script:PSPkgMgmt = 'Microsoft.PowerShell.PackageManagement.dll' 16 | 17 | 18 | # Try to import the OneGet assemblies 19 | $OneGetModulePath = Join-Path -Path $script:PSModuleRoot -ChildPath $script:PkgMgmt 20 | $binaryModuleRoot = $script:PSModuleRoot 21 | 22 | 23 | if(-not (Test-Path -Path $OneGetModulePath)) 24 | { 25 | # Import the appropriate nested binary module based on the current PowerShell version 26 | $binaryModuleRoot = Join-Path -Path $script:PSModuleRoot -ChildPath $binarySubPath 27 | $OneGetModulePath = Join-Path -Path $binaryModuleRoot -ChildPath $script:PkgMgmt 28 | } 29 | 30 | $PSOneGetModulePath = Join-Path -Path $binaryModuleRoot -ChildPath $script:PSPkgMgmt 31 | $OneGetModule = Import-Module -Name $OneGetModulePath -PassThru 32 | $PSOneGetModule = Import-Module -Name $PSOneGetModulePath -PassThru 33 | 34 | 35 | # When the module is unloaded, remove the nested binary module that was loaded with it 36 | if($OneGetModule) 37 | { 38 | $script:PSModule.OnRemove = { 39 | Remove-Module -ModuleInfo $OneGetModule 40 | } 41 | } 42 | 43 | if($PSOneGetModule) 44 | { 45 | $script:PSModule.OnRemove = { 46 | Remove-Module -ModuleInfo $PSOneGetModule 47 | } 48 | } -------------------------------------------------------------------------------- /src/Microsoft.PowerShell.PackageManagement/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | // 14 | 15 | using System.Reflection; 16 | using System.Runtime.CompilerServices; 17 | using System.Runtime.InteropServices; 18 | 19 | // General Information about an assembly is controlled through the following 20 | // set of attributes. Change these attribute values to modify the information 21 | // associated with an assembly. 22 | 23 | //[assembly: AssemblyTitle("Microsoft.PowerShell.PackageManagement")] 24 | //[assembly: AssemblyDescription("PackageManagement PowerShell Module Implementation")] 25 | //[assembly: AssemblyConfiguration("")] 26 | //[assembly: AssemblyCompany("Microsoft")] 27 | //[assembly: AssemblyProduct("Microsoft.PowerShell.PackageManagement")] 28 | //[assembly: AssemblyCopyright("Copyright © Microsoft 2014")] 29 | //[assembly: AssemblyTrademark("")] 30 | //[assembly: AssemblyCulture("")] 31 | [assembly: AssemblyFileVersionAttribute("3.0.0.0")] 32 | [assembly: AssemblyVersion("3.0.0.0")] 33 | 34 | 35 | // Normally, we wouldn't actaully permit access to the internals of the PackageManagement module 36 | // but we're sharing code with the other our tightly-coupled Chocolatey PowerShell module 37 | 38 | [assembly: InternalsVisibleTo(@"Microsoft.PackageManagement.Test" + @",PublicKey=0024000004800000940000000602000000240000525341310004000001000100b5fc90e7027f67871e773a8fde8938c81dd402ba65b9201d60593e96c492651e889cc13f1415ebb53fac1131ae0bd333c5ee6021672d9718ea31a8aebd0da0072f25d87dba6fc90ffd598ed4da35e44c398c454307e8e33b8426143daec9f596836f97c8f74750e5975c64e2189f45def46b2a2b1247adc3652bf5c308055da9")] 39 | 40 | // Setting ComVisible to false makes the types in this assembly not visible 41 | // to COM components. If you need to access a type in this assembly from 42 | // COM, set the ComVisible attribute to true on that type. 43 | 44 | //[assembly: ComVisible(false)] 45 | 46 | // The following GUID is for the ID of the typelib if this project is exposed to COM 47 | 48 | //[assembly: Guid("cef75504-d220-4860-b2df-4863f1d5c2ec")] 49 | -------------------------------------------------------------------------------- /src/Microsoft.PowerShell.PackageManagement/Utility/ErrorMessage.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | // 14 | 15 | namespace Microsoft.PowerShell.PackageManagement.Utility { 16 | using System.Management.Automation; 17 | 18 | internal class ErrorMessage { 19 | public readonly ErrorCategory Category; 20 | public readonly string Resource; 21 | 22 | public ErrorMessage(string resource, ErrorCategory category) { 23 | Resource = resource; 24 | Category = category; 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/Microsoft.PowerShell.PackageManagement/Utility/ProgressTracker.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | // 14 | 15 | namespace Microsoft.PowerShell.PackageManagement.Utility { 16 | using System.Collections.Generic; 17 | 18 | internal class ProgressTracker { 19 | internal string Activity; 20 | internal List Children = new List(); 21 | internal int Id; 22 | internal ProgressTracker Parent; 23 | } 24 | } -------------------------------------------------------------------------------- /src/Microsoft.PowerShell.PackageManagement/Utility/WebProxy.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Net; 3 | 4 | namespace Microsoft.PowerShell.PackageManagement.Utility 5 | { 6 | /// 7 | /// Used by OneGet cmdlet to supply webproxy to provider 8 | /// We cannot use System.Net.WebProxy because this is not available on CoreClr 9 | /// 10 | internal class InternalWebProxy : IWebProxy 11 | { 12 | Uri _proxyUri; 13 | ICredentials _credentials; 14 | 15 | public InternalWebProxy(Uri uri, ICredentials credentials) 16 | { 17 | Credentials = credentials; 18 | _proxyUri = uri; 19 | } 20 | 21 | /// 22 | /// Credentials used by WebProxy 23 | /// 24 | public ICredentials Credentials 25 | { 26 | get 27 | { 28 | return _credentials; 29 | } 30 | set 31 | { 32 | _credentials = value; 33 | } 34 | } 35 | 36 | public Uri GetProxy(Uri destination) 37 | { 38 | return _proxyUri; 39 | } 40 | 41 | public bool IsBypassed(Uri host) 42 | { 43 | return false; 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/signing/35MSSharedLib1024.snk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OneGet/oneget/d25ee92d7b3195c0bcf6f0a6162bd928418f20f6/src/signing/35MSSharedLib1024.snk -------------------------------------------------------------------------------- /test.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OneGet/oneget/d25ee92d7b3195c0bcf6f0a6162bd928418f20f6/test.ps1 -------------------------------------------------------------------------------- /tools/mt.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OneGet/oneget/d25ee92d7b3195c0bcf6f0a6162bd928418f20f6/tools/mt.exe -------------------------------------------------------------------------------- /tools/travis.sh: -------------------------------------------------------------------------------- 1 | set -x 2 | ulimit -n 4096 3 | 4 | 5 | git submodule update --init 6 | 7 | 8 | pwsh -c "cd src; ./bootstrap.ps1; ./build.ps1 -framework "netstandard2.0" Release" 9 | sudo pwsh -c "cd Test; ./run-tests.ps1 coreclr -nugetApiVersion $1" --------------------------------------------------------------------------------