Skip to content

Commit

Permalink
Merge pull request #25 from SkylineCommunications/NonCSharpExeInSolut…
Browse files Browse the repository at this point in the history
…ionWithLibrary

Fixed issue with non C# exe in a solution that contains a library
  • Loading branch information
janstaelensskyline authored Feb 7, 2024
2 parents e221b6e + bd13cea commit 445d95d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
17 changes: 12 additions & 5 deletions Assemblers.Automation/AutomationScriptBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class AutomationScriptBuilder
/// <exception cref="ArgumentNullException"><paramref name="script"/> is <see langword="null"/>.</exception>
[Obsolete("Use the constructor with the solutionDirectory so it can take in account the NuGet.config from the solution.")]
public AutomationScriptBuilder(Script script, IDictionary<string, Project> projects, IEnumerable<Script> allScripts)
: this(script, projects, allScripts, solutionDirectory: null)
: this(script, projects, allScripts, solutionDirectory: null)
{
}

Expand Down Expand Up @@ -102,7 +102,7 @@ public AutomationScriptBuilder(Script script, IDictionary<string, Project> proje

private IDictionary<string, Project> Projects { get; }

private IEnumerable<Script> AllScripts { get; }
private IEnumerable<Script> AllScripts { get; }

/// <summary>
/// Combines all the cs files in the project into a single string.
Expand Down Expand Up @@ -131,6 +131,13 @@ public static string CombineProjectFiles(Project project)
/// <returns>True when finding the project name. Otherwise false.</returns>
public static bool TryFindProjectPlaceholder(string text, out string projectName, out Match match)
{
if (String.IsNullOrWhiteSpace(text))
{
match = null;
projectName = null;
return false;
}

match = RegexProjectPlaceholder.Match(text);
if (match.Success)
{
Expand Down Expand Up @@ -201,7 +208,7 @@ private async Task<NuGetPackageAssemblyData> ProcessPackageReferences(EditXml.Xm
{
nugetAssemblyData = await packageReferenceProcessor.ProcessAsync(packageIdentities, project.TargetFrameworkMoniker, DevPackHelper.AutomationDevPackNuGetDependenciesIncludingTransitive).ConfigureAwait(false);
LogDebug($"NuGetPackageAssemblyData: {nugetAssemblyData}");

ProcessFrameworkAssemblies(editExe, nugetAssemblyData);
ProcessLibAssemblies(editExe, buildResultItems, nugetAssemblyData);
}
Expand Down Expand Up @@ -425,7 +432,7 @@ private void ProcessReference(Reference r, EditXml.XmlElement editExe, NuGetPack
LogDebug($"ProcessReference|Add Param for {dll}");
AddOrUpdateReferenceInExeBlock(_fileSystem, dll, editExe);
}

private static void AddOrUpdateReferenceInExeBlock(IFileSystem fs, string dll, EditXml.XmlElement editExe)
{
if (HasDllImport(fs, editExe, dll, out var existing))
Expand Down Expand Up @@ -592,7 +599,7 @@ private void BuildScriptReferences(EditXml.XmlElement editExe, Project project)
}
}

private (string scriptName, ScriptExe scriptExe)FindExeFromOtherScript(Project project, ProjectReference r)
private (string scriptName, ScriptExe scriptExe) FindExeFromOtherScript(Project project, ProjectReference r)
{
// Check if the exe block belongs to another script.
foreach (var script in AllScripts)
Expand Down
2 changes: 2 additions & 0 deletions Assemblers.AutomationTests/AutomationScriptBuilderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ public class AutomationScriptBuilderTests
[TestMethod]
[DataRow("[Project:SVD-1_2]", "SVD-1_2")]
[DataRow("[Project:TV2D-SRM-LSO.Satellite Downlink [DVB-S2.S2X]_63000]", "TV2D-SRM-LSO.Satellite Downlink [DVB-S2.S2X]_63000")]
[DataRow("", null)]
[DataRow(null, null)]
public void SLDisCompiler_AutomationScriptBuilder_TryFindProjectPlaceholder(string text, string expectedOutput)
{
// Act
Expand Down

0 comments on commit 445d95d

Please sign in to comment.