Exemplo n.º 1
0
        private async Task FileSystemChanged(MsBuildFileSystemWatcher.Changeset changeset)
        {
            _log.ApplyProjectChangesStarted();

            if (_unloadCancellationToken.IsCancellationRequested)
            {
                return;
            }

            try {
                using (var access = await _projectLockService.WriteLockAsync(_unloadCancellationToken)) {
                    await access.CheckoutAsync(_inMemoryImportFullPath);

                    _temporaryAddedItemGroup.RemoveAllChildren();

                    await RemoveFiles(changeset.RemovedFiles, access);
                    await RemoveDirectories(changeset.RemovedDirectories, access);

                    await RenameFiles(changeset.RenamedFiles, access);
                    await RenameDirectories(changeset.RenamedDirectories, access);

                    AddDirectories(changeset.AddedDirectories);
                    AddFiles(changeset.AddedFiles);

                    _log.MsBuildAfterChangesApplied(_inMemoryImport);

                    foreach (var configuredProject in _unconfiguredProject.LoadedConfiguredProjects)
                    {
                        try {
                            var project =
                                await access.GetProjectAsync(configuredProject, _unloadCancellationToken);

                            project.ReevaluateIfNecessary();
                        } catch (Exception ex) {
                            Trace.Fail("Unable to mark a configuration as dirty" + ex.Message, ex.StackTrace);
                        }
                    }
                }
            } catch (Exception ex) {
                Trace.Fail("Unable to handle file system change:" + ex.Message, ex.StackTrace);
            }

            _log.ApplyProjectChangesFinished();
        }