Пример #1
0
        /// <summary>
        /// Register a host object for a particular task/target pair.
        /// Overwrites any existing host object.
        /// </summary>
        public void RegisterHostObject(string projectFile, string targetName, string taskName, ITaskHost hostObject)
        {
/* Unmerged change from project 'Microsoft.Build (netcoreapp2.1)'
 * Before:
 *          ErrorUtilities.VerifyThrowArgumentNull(projectFile, "projectFile");
 *          ErrorUtilities.VerifyThrowArgumentNull(targetName, "targetName");
 * After:
 *          ErrorUtilities.VerifyThrowArgumentNull(projectFile, "projectFile));
 *          ErrorUtilities.VerifyThrowArgumentNull(targetName, "targetName));
 */
            ErrorUtilities.VerifyThrowArgumentNull(projectFile, nameof(projectFile));
            ErrorUtilities.VerifyThrowArgumentNull(targetName, nameof(targetName));
            ErrorUtilities.VerifyThrowArgumentNull(taskName, nameof(taskName));

            // We can only set the host object to a non-null value if the affinity for the project is not out of proc, or if it is, it is only implicitly
            // out of proc, in which case it will become in-proc after this call completes.  See GetNodeAffinity.
            bool isExplicit;
            bool hasExplicitOutOfProcAffinity = (GetNodeAffinity(projectFile, out isExplicit) == NodeAffinity.OutOfProc) && isExplicit;

            ErrorUtilities.VerifyThrowInvalidOperation(!hasExplicitOutOfProcAffinity || hostObject == null, "InvalidHostObjectOnOutOfProcProject");
            _hostObjectMap ??= new Dictionary <string, HostObjects>(StringComparer.OrdinalIgnoreCase);

            HostObjects hostObjects = GetHostObjectsFromMapByKeyOrCreateNew(projectFile);

            hostObjects.RegisterHostObject(targetName, taskName, hostObject);
        }
Пример #2
0
        /// <summary>
        /// Register a remote host object for a particular task/target pair.
        /// The remote host object require registered in Running Object Table(ROT) already.
        /// Overwrites any existing host object.
        ///
        /// It's caller's responsibly:
        /// To maintain the live cycle of the host object.
        /// Register and unregister from ROT.
        /// Ensure the host object has appropriate COM interface that can be used in task.
        /// </summary>
        /// <param name="projectFile">project file name</param>
        /// <param name="targetName">target name</param>
        /// <param name="taskName">task name</param>
        /// <param name="monikerName">the Moniker used to register host object in ROT</param>
        public void RegisterHostObject(string projectFile, string targetName, string taskName, string monikerName)
        {
            ErrorUtilities.VerifyThrowArgumentNull(projectFile, nameof(projectFile));
            ErrorUtilities.VerifyThrowArgumentNull(targetName, nameof(targetName));
            ErrorUtilities.VerifyThrowArgumentNull(taskName, nameof(taskName));
            ErrorUtilities.VerifyThrowArgumentNull(monikerName, nameof(monikerName));

            _hostObjectMap ??= new Dictionary <string, HostObjects>(StringComparer.OrdinalIgnoreCase);

            HostObjects hostObjects = GetHostObjectsFromMapByKeyOrCreateNew(projectFile);

            hostObjects.RegisterHostObject(targetName, taskName, monikerName);
        }
Пример #3
0
        /// <summary>
        /// Register a remote host object for a particular task/target pair.
        /// The remote host object require registered in Running Object Table(ROT) already.
        /// Overwrites any existing host object.
        ///
        /// It's caller's responsibly:
        /// To maintain the live cycle of the host object.
        /// Register and unregister from ROT.
        /// Ensure the host object has appropriate COM interface that can be used in task.
        /// </summary>
        /// <param name="monikerName">the Moniker used to register host object in ROT</param>
        public void RegisterHostObject(string projectFile, string targetName, string taskName, string monikerName)
        {
            ErrorUtilities.VerifyThrowArgumentNull(projectFile, "projectFile");
            ErrorUtilities.VerifyThrowArgumentNull(targetName, "targetName");
            ErrorUtilities.VerifyThrowArgumentNull(taskName, "taskName");
            ErrorUtilities.VerifyThrowArgumentNull(monikerName, "monikerName");

            if (Environment.Is64BitProcess)
            {
                throw new PlatformNotSupportedException("RegisterHostObject with monikerName is only supported in 32 bit");
            }

            _hostObjectMap = _hostObjectMap ?? new Dictionary <string, HostObjects>(StringComparer.OrdinalIgnoreCase);

            HostObjects hostObjects = GetHostObjectsFromMapByKeyOrCreateNew(projectFile);

            hostObjects.RegisterHostObject(targetName, taskName, monikerName);
        }