Skip to content

Commit

Permalink
Fixed handling of TargetFramework property if it is blank. Fixes #923.
Browse files Browse the repository at this point in the history
  • Loading branch information
EWSoftware committed Nov 4, 2022
1 parent d65b4f9 commit 2b55945
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 deletions.
27 changes: 13 additions & 14 deletions SHFB/Source/SandcastleBuilderGUI/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// System : Sandcastle Help File Builder
// File : MainForm.cs
// Author : Eric Woodruff ([email protected])
// Updated : 04/25/2021
// Note : Copyright 2006-2021, Eric Woodruff, All rights reserved
// Updated : 11/04/2022
// Note : Copyright 2006-2022, Eric Woodruff, All rights reserved
//
// This file contains the main form for the application.
//
Expand Down Expand Up @@ -252,8 +252,6 @@ private IDockContent DeserializeState(string persistString)
/// <param name="mustExist">True if it must exist or false if it is a new, unnamed project</param>
private void CreateProject(string projectName, bool mustExist)
{
List<string> values;

project = new SandcastleProject(projectName, mustExist, false);

projectExplorer.CurrentProject = projectProperties.CurrentProject = project;
Expand All @@ -264,25 +262,26 @@ private void CreateProject(string projectName, bool mustExist)
this.UpdateFilenameInfo();

// Get the configuration and platform values
values = project.MSBuildProject.ConditionedProperties["Configuration"];

tcbConfig.Items.Clear();
tcbPlatform.Items.Clear();

foreach(string value in values)
tcbConfig.Items.Add(value);
if(project.MSBuildProject.ConditionedProperties.TryGetValue("Configuration", out var values))
{
foreach(string value in values)
tcbConfig.Items.Add(value);
}

if(tcbConfig.Items.Count == 0)
{
tcbConfig.Items.Add("Debug");
tcbConfig.Items.Add("Release");
}

values = project.MSBuildProject.ConditionedProperties["Platform"];

tcbPlatform.Items.Clear();

foreach(string value in values)
tcbPlatform.Items.Add(value);
if(project.MSBuildProject.ConditionedProperties.TryGetValue("Platform", out values))
{
foreach(string value in values)
tcbPlatform.Items.Add(value);
}

if(tcbPlatform.Items.Count == 0)
tcbPlatform.Items.Add("AnyCPU");
Expand Down
5 changes: 4 additions & 1 deletion SHFB/Source/SandcastleBuilderUtils/MSBuild/MSBuildProject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -344,8 +344,11 @@ public string TargetFramework
if(properties == null)
throw new InvalidOperationException("Configuration has not been set");

if(properties.TryGetValue("TargetFramework", out ProjectProperty prop))
if(properties.TryGetValue("TargetFramework", out ProjectProperty prop) &&
!String.IsNullOrWhiteSpace(prop.EvaluatedValue))
{
return prop.EvaluatedValue;
}

// If multi-targeting, return the requested target type if present or the first one if not
if(this.TargetFrameworks.Any())
Expand Down

0 comments on commit 2b55945

Please sign in to comment.