// internal for testing, settings parameter to allow testing without messing with the static variable internal void RunFinished(ModelBuilderSettings settings, string targetDirectory) { // null indicates an error when generating code if (_generatedCode == null) { return; } var project = settings.Project; var filesToSave = _generatedCode.Skip(1) .ToDictionary(kvp => Path.Combine(targetDirectory, kvp.Key), kvp => (object)kvp.Value); try { _vsUtils.WriteCheckoutTextFilesInProject(filesToSave); } finally { // even if saving fails we actually might have created some files // and we should add them to the project AddFilesToProject(project, filesToSave.Keys); } _configFileUtils = _configFileUtils ?? new ConfigFileUtils( project, PackageManager.Package, settings.VSApplicationType); UpdateConfigFile(settings); }