コード例 #1
0
        public override bool Execute()
        {
            if (LaunchProfiles == null || UserFile == null || FlagFile == null || ProjectDirectory == null)
            {
                Log.LogWarning("MonitorActiveDocument : One or more files missing");
                return(true);
            }

            if (!Directory.Exists(LaunchProfiles))
            {
                Log.LogWarning("LaunchProfiles not created yet");
                return(true);
            }
            try
            {
                if (BuildEngine4.GetRegisteredTaskObject(nameof(ActiveDocumentMonitor), RegisteredTaskObjectLifetime.AppDomain) is not ActiveDocumentMonitor monitor)
                {
                    if (WindowsInterop.GetServiceProvider() is IServiceProvider services)
                    {
                        BuildEngine4.RegisterTaskObject(nameof(ActiveDocumentMonitor),
                                                        new ActiveDocumentMonitor(LaunchProfiles, UserFile, FlagFile, ProjectDirectory, services),
                                                        RegisteredTaskObjectLifetime.AppDomain, false);
                    }
                }
                else
                {
                    // NOTE: this means we only support ONE project/launchProfiles per IDE.
                    monitor.Refresh(LaunchProfiles, UserFile, FlagFile, ProjectDirectory);
                }
            }
コード例 #2
0
        public override bool Execute()
        {
            if (FlagFile == null || StartupFile == null)
            {
                return(true);
            }
            if (!File.Exists(FlagFile) || File.ReadAllText(FlagFile) != StartupFile)
            {
                // This defers the opening until the build completes.
                BuildEngine4.RegisterTaskObject(
                    StartupFile,
                    new DisposableAction(() => WindowsInterop.EnsureOpened(StartupFile)),
                    RegisteredTaskObjectLifetime.Build, false);

                File.WriteAllText(FlagFile, StartupFile);
            }

            return(true);
        }