protected SetConfiguration ( string configKey ) : void | ||
configKey | string | Configuration name |
리턴 | void |
protected internal virtual void SetConfiguration(string configKey)
{
if (configKey == null)
throw new ArgumentNullException("configKey");
// Can't ask for the active config until the project is opened, so do nothing in that scenario
if (!projectOpened)
return;
// We cannot change properties during the build so if the config
// we want to se is the current, we do nothing otherwise we fail.
if (this.BuildInProgress)
{
var currentConfigKey = ProjectConfig.TryGetActiveConfigurationAndPlatform(ServiceProvider, this);
if (ProjectConfig.Eq(currentConfigKey, configKey))
return;
throw new InvalidOperationException("Can't set other configuration during a build in progress.");
}
string configName;
string platformName;
if (!ProjectConfig.TrySplitConfigurationCanonicalName(configKey, out configName, out platformName))
configName = configKey;
bool propertiesChanged = this.buildProject.SetGlobalProperty(ProjectFileConstants.Configuration, configName);
if (!string.IsNullOrWhiteSpace(platformName))
propertiesChanged |= this.buildProject.SetGlobalProperty(ProjectFileConstants.Platform, ProjectConfig.ToMSBuildPlatform(platformName));
//this.buildProject.ReevaluateIfNecessary(); //???
if (this.currentConfig == null || propertiesChanged)
this.currentConfig = this.buildProject.CreateProjectInstance();
if (propertiesChanged || this.designTimeAssemblyResolution == null)
{
if (this.designTimeAssemblyResolution == null)
this.designTimeAssemblyResolution = new DesignTimeAssemblyResolution();
this.designTimeAssemblyResolution.Initialize(this);
}
this.options = null;
}
protected virtual void Refresh() { // Let MSBuild know which configuration we are working with project.SetConfiguration(projectCfg.ConfigName); // Generate dependencies if such a task exist const string generateDependencyList = "AllProjectOutputGroups"; if (project.BuildProject.Targets.ContainsKey(generateDependencyList)) { bool succeeded; project.BuildTarget(generateDependencyList, out succeeded); Debug.Assert(succeeded, "Failed to build target: " + generateDependencyList); } // Rebuild the content of our list of output string outputType = this.targetName + "Output"; this.outputs.Clear(); foreach (MSBuildExecution.ProjectItemInstance assembly in project.CurrentConfig.GetItems(outputType)) { Output output = new Output(project, assembly); this.outputs.Add(output); // See if it is our key output if (String.Compare(assembly.GetMetadataValue("IsKeyOutput"), true.ToString(), StringComparison.OrdinalIgnoreCase) == 0) { keyOutput = output; } } project.SetCurrentConfiguration(); // Now that the group is built we have to check if it is invalidated by a property // change on the project. project.OnProjectPropertyChanged += new EventHandler <ProjectPropertyChangedArgs>(OnProjectPropertyChanged); }