Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion MvsSln
Submodule MvsSln updated 106 files
13 changes: 9 additions & 4 deletions vsSolutionBuildEvent/EnvAbstract.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ public abstract class EnvAbstract
/// </summary>
public abstract string SolutionFile { get; protected set; }

protected abstract ConfigItem ActiveSlnConf { get; }

protected abstract void UpdateSlnEnv(ISlnResult sln);

/// <summary>
Expand Down Expand Up @@ -108,16 +110,19 @@ public virtual EProject getProject(string name = null)

Log.Trace($"getProject: started with '{name}' /{StartupProjectString}");

if(String.IsNullOrEmpty(name)) {
name = StartupProjectString;
}
if(string.IsNullOrEmpty(name)) name = StartupProjectString;

ProjectItem project = Sln.ProjectItems.FirstOrDefault(p => p.name == name);
if(project.fullPath == null) {
throw new NotFoundException($"Project '{name}' was not found. ['{project.name}', '{project.pGuid}']");
}

return SlnEnv?.GetOrLoadProject(project);
IConfPlatformPrj cfg = Sln.ProjectItemsConfigs
.FirstOrDefault(p => ActiveSlnConf?.Equals(p.solutionConfig) == true)
.projectConfig;

return (cfg == null) ? SlnEnv?.GetOrLoadProject(project)
: SlnEnv?.GetOrLoadProject(project, cfg);
}

/// <summary>
Expand Down
24 changes: 20 additions & 4 deletions vsSolutionBuildEvent/Environment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,12 @@ public class Environment: EnvAbstract, IEnvironment, IEnvironmentExt, IEvEnv

private string startupProject;

private ConfigItem currentSlnConf;

/// <summary>
/// List of EnvDTE projects.
/// </summary>
public IEnumerable<DProject> ProjectsDTE
{
get => _DTEProjects;
}
public IEnumerable<DProject> ProjectsDTE => _DTEProjects;

/// <summary>
/// List of Microsoft.Build.Evaluation projects.
Expand Down Expand Up @@ -283,6 +282,23 @@ protected IEnumerable<DProject> DTEProjectsRaw
}
}

protected override ConfigItem ActiveSlnConf
{
get
{
SolutionConfiguration2 cfg = SolutionActiveCfg;
if(cfg == null) return null;

if(currentSlnConf?.IsEqualByRule(cfg.Name, cfg.PlatformName) == true)
{
return currentSlnConf;
}

currentSlnConf = new(cfg.Name, cfg.PlatformName);
return currentSlnConf;
}
}

/// <summary>
/// An unified unscoped and out of Project instance the property value by its name.
/// Remarks: Any property values cannot be null.
Expand Down
20 changes: 15 additions & 5 deletions vsSolutionBuildEvent/IsolatedEnv.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ public class IsolatedEnv: EnvAbstract, IEnvironment, IEvEnv

protected readonly IConfPlatform defaultCfg = new ConfigSln("Debug", "Any CPU");

private ConfigItem currentSlnConf;

private string _startupProjectString;

private readonly IDictionary<string, string> _properties;
Expand Down Expand Up @@ -178,6 +180,8 @@ public IOW OutputWindowPane
get => __disabled<IOW>(nameof(OutputWindowPane));
}

protected override ConfigItem ActiveSlnConf => extractCfg(slnProperties);

/// <summary>
/// An unified unscoped and out of Project instance the property value by its name.
/// Remarks: Any property values cannot be null.
Expand Down Expand Up @@ -292,14 +296,20 @@ void _SetIfNull(string key, string value)
return properties;
}

protected IConfPlatform extractCfg(IDictionary<string, string> properties)
protected ConfigItem extractCfg(IDictionary<string, string> properties)
{
IConfPlatform def = Sln?.DefaultConfig;

return new ConfigItem(
properties.GetOrDefault(PropertyNames.CONFIG, def?.Configuration),
properties.GetOrDefault(PropertyNames.PLATFORM, def?.Platform)
);
string configuration = properties.GetOrDefault(PropertyNames.CONFIG, def?.Configuration);
string platform = properties.GetOrDefault(PropertyNames.PLATFORM, def?.Platform);

if(currentSlnConf?.IsEqualByRule(configuration, platform) == true)
{
return currentSlnConf;
}

currentSlnConf = new(configuration, platform);
return currentSlnConf;
}

protected string formatCfg(IDictionary<string, string> properties)
Expand Down