Represents a package action entry in the answer file. A package action is created for a package in a Windows image or from a package file. Namespace: Microsoft.ComponentStudio.ComponentPlatformInterface
Assembly: Microsoft.ComponentStudio.ComponentPlatformInterface (in microsoft.componentstudio.componentplatforminterface.dll)

Usage

Visual Basic
Dim packageAction1 As PackageAction

Syntax

Visual Basic
Public Class PackageAction
		Inherits ObjectBase
		Implements IRemovable, ICustomTypeDescriptor
C#
public class PackageAction : ObjectBase, IRemovable, ICustomTypeDescriptor
C++
public ref class PackageAction : ObjectBase, IRemovable, ICustomTypeDescriptor
J#
public class PackageAction extends ObjectBase implements IRemovable, ICustomTypeDescriptor
JScript
public class PackageAction extends ObjectBase implements IRemovable, , ICustomTypeDescriptor

Example

In this example, you start by declaring the paths of the answer file, the Windows image file, and the distribution share folder on your machine. Then you open the offline image and create an answer file. You also open a package from a specific path in the distribution share, and then create a package action by using the answer file and the package objects. Finally, you display some of the package action properties.

noteNote:
To run this example, you must change the value of the variables wimPath and distShare to the paths that contain the .wim file and the distribution share on your machine, respectively. You must also change the value of the variable answerFile to the name of the answer file on your machine.
// PackageAction.cs

using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;
using Microsoft.ComponentStudio.ComponentPlatformInterface;

namespace MyNameSpace
{
	public class MyClass
	{
		static void Main()
		{
			string wimPath = @"C:\myWorkingFolder";
			string wimFile = wimPath + @"\install.wim";
			string answerFile = wimPath + @"\myUnattend.xml";
			string distShare = @"C:\DistributionShare";

			// Create a Cpi instance:
			Cpi n = Cpi.Instance;

			// Check if the catalog file is created; 
			// if not create one:
			WimInfo wimInfo = n.OpenWim(wimFile);
			if (!wimInfo.Images[0].ValidateCatalog().Succeeded)
				wimInfo.Images[0].CreateCatalog();

			// Open the offline image:
			OfflineImage image = n.OpenOfflineImage(wimInfo.Images[0]);  

			// Create an answer file:
			AnswerFile ua = n.CreateAnswerFile(image);

			// Open a package from a specific path:
			Package pkg = n.OpenPackage(
				distShare + @"\Packages\HotFix\Calc.package");
		
			// Create a package action:
			PackageAction pa = ua.PackageActions.Create(pkg,
				CreateOptions.ReturnExisting); 

			// Display the package action properties:
			Console.WriteLine("PackageAction name: {0}", pa);
			Console.WriteLine("Action: {0}", pa.Action);
			Console.WriteLine("Permanence type: {0}", 
				pa.PermanenceType);
	}
}
}
/* Output:
PackageAction name: Calculator Demo
Action: Install
Permanence type: Removable
*/

Remarks

Instances of PackageAction can be created by calling one of the Create methods in PackageActionCollection.

A package action is created for a package in a Windows image or from a package file.


Inheritance Hierarchy

System.Object
   Microsoft.ComponentStudio.Common.ObjectBase
    Microsoft.ComponentStudio.ComponentPlatformInterface.PackageAction

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Platforms

Development Platforms

Windows XP Home Edition, Windows XP Professional, Windows Server 2003, Windows Vista, and Windows 2000

Target Platforms

See Also

[an error occurred while processing this directive]