none
HCK Object Model obtain project from package RRS feed

  • Question

  • Hello,

    In HCK, we have a submission package, and from that, need to get a project.  How is this done in the Object Model?  (The original project is already deleted).

    Thanks!


    • Edited by hh-hh-hh Monday, December 16, 2013 11:48 PM
    Monday, December 16, 2013 11:48 PM

Answers

  • Getting a project from a package would be similar to getting a project from a database. The only difference is that you use PackageManager instead of DatabaseProjectManager -

    PackagerManager pm = new PackageManager(filename);
    string projectName = pm.GetProjectNames().FirstOrDefault();
    Project prj = pm.GetProject(projecName);
    I think you would find it helpful to review the ProjectManager class - http://msdn.microsoft.com/en-us/library/windows/hardware/hh998133.aspx. This is an base/abstract class for DatabaseProjectManager and PackageManager objects.


    John -- This posting is provided "AS IS" with no warranties, and confers no rights.


    • Edited by John Garcia (HCK) Wednesday, December 18, 2013 4:55 PM
    • Marked as answer by hh-hh-hh Wednesday, December 18, 2013 9:21 PM
    Wednesday, December 18, 2013 4:52 PM

All replies

  • Getting a project from a package would be similar to getting a project from a database. The only difference is that you use PackageManager instead of DatabaseProjectManager -

    PackagerManager pm = new PackageManager(filename);
    string projectName = pm.GetProjectNames().FirstOrDefault();
    Project prj = pm.GetProject(projecName);
    I think you would find it helpful to review the ProjectManager class - http://msdn.microsoft.com/en-us/library/windows/hardware/hh998133.aspx. This is an base/abstract class for DatabaseProjectManager and PackageManager objects.


    John -- This posting is provided "AS IS" with no warranties, and confers no rights.


    • Edited by John Garcia (HCK) Wednesday, December 18, 2013 4:55 PM
    • Marked as answer by hh-hh-hh Wednesday, December 18, 2013 9:21 PM
    Wednesday, December 18, 2013 4:52 PM
  • John,

    Thank you very much!  That worked : )

    Here is the PowerShell version that I now have:

        $packageManager1 = New-Object -TypeName Microsoft.Windows.Kits.Hardware.ObjectModel.Submission.PackageManager -Args $package1
        $project1name = $packageManager1.GetProjectNames()[0]
        if ($project1name -eq $null)
        {
            Write-Host "Unable to get project1name `n" $error.ToString() -ForegroundColor Red
        }
    
        $project1 = $packageManager1.GetProject($project1name)
    
        Write-Host "Project 1: $project1, $($project1.Name)"
    
    

    Wednesday, December 18, 2013 9:21 PM