Skip to content

Commit

Permalink
fix: don't throw when project-id for project-platform-configuration d…
Browse files Browse the repository at this point in the history
…oes not exist (#17)

* chore: use net6.0 instead of net5.0

for build and test, because net5.0 is out of support

* fix: fix exception when project for project-platform-configuration could not be found

because this is not an issue with IDEs that use sln-files

* build: use net6.0
  • Loading branch information
wgnf authored Nov 19, 2022
1 parent 859a79d commit 5dfd334
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ jobs:
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 5.0.x
dotnet-version: 6.0.x
- name: Run Build and Test using Nuke
run: ./build.ps1 -Target Test -Configuration Release
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ jobs:
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 5.0.x
dotnet-version: 6.0.x
- name: Run Publish using Nuke
run: ./build.ps1 -Target Publish -Configuration Release --nuget_api_key ${{ secrets.NUGET_API_KEY }}
6 changes: 3 additions & 3 deletions build/SlnParser.Build.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<RootNamespace></RootNamespace>
<NoWarn>CS0649;CS0169</NoWarn>
<NukeRootDirectory>..</NukeRootDirectory>
Expand All @@ -11,8 +11,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Nuke.Common" Version="5.3.0"/>
<PackageDownload Include="GitVersion.CommandLine" Version="[5.5.1]"></PackageDownload>
<PackageReference Include="Nuke.Common" Version="5.3.0" />
<PackageDownload Include="GitVersion.CommandLine" Version="[5.5.1]" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion src/SlnParser.Tests/SlnParser.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
Expand Down
1 change: 1 addition & 0 deletions src/SlnParser.Tests/Solutions/TestSln.sln
Original file line number Diff line number Diff line change
Expand Up @@ -118,5 +118,6 @@ Global
{20AD21B6-0ABB-4DB5-8BA0-D9896E58E3E4}.Release|x64.Build.0 = Release|Any CPU
{20AD21B6-0ABB-4DB5-8BA0-D9896E58E3E4}.Release|x86.ActiveCfg = Release|Any CPU
{20AD21B6-0ABB-4DB5-8BA0-D9896E58E3E4}.Release|x86.Build.0 = Release|Any CPU
{2FD6FF99-971A-470A-BB0D-CE738AB29D6C}.Debug|x64.ActiveCfg = Debug|Any CPU
EndGlobalSection
EndGlobal
4 changes: 2 additions & 2 deletions src/SlnParser/Contracts/Helper/NestedProjectMapping.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ public NestedProjectMapping(
DestinationId = new Guid(destinationId);
}

public Guid TargetId { get; set; }
public Guid TargetId { get; }

public Guid DestinationId { get; set; }
public Guid DestinationId { get; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ public void Enrich(Solution solution, IEnumerable<string> fileContents)
}

private static void MapConfigurationPlatformsToProjects(
Solution solution,
ISolution solution,
IEnumerable<ProjectConfigurationPlatform> projectConfigurations)
{
foreach (var configuration in projectConfigurations)
MapConfigurationPlatformToProject(solution, configuration);
}

private static void MapConfigurationPlatformToProject(
Solution solution,
ISolution solution,
ProjectConfigurationPlatform configuration)
{
if (!configuration.ProjectId.HasValue)
Expand All @@ -44,11 +44,7 @@ private static void MapConfigurationPlatformToProject(
.AllProjects
.FirstOrDefault(project => project.Id == configuration.ProjectId.Value);

if (project == null)
throw new UnexpectedSolutionStructureException(
"Expected to find a project with the id " +
$"'{configuration.ProjectId.Value}' for the Project-Platform-Configuration " +
$"'{configuration.ConfigurationPlatform.Name}'");
if (project == null) return;

if (!(project is SolutionProject solutionProject))
throw new UnexpectedSolutionStructureException(
Expand Down
4 changes: 2 additions & 2 deletions src/SlnParser/Helper/EnrichSolutionWithSolutionFolderFiles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ private void DetermineProjectItemsSection(string line)
_inASolutionItemsSection = line.StartsWith("ProjectSection(SolutionItems)");
}

private void AddSolutionItemFile(Solution solution, string line)
private void AddSolutionItemFile(ISolution solution, string line)
{
if (!_inASolutionItemsSection) return;

Expand All @@ -100,7 +100,7 @@ private void AddSolutionItemFile(Solution solution, string line)
}

private static bool TryGetSolutionItemFile(
Solution solution,
ISolution solution,
string line,
out FileInfo solutionItemFile)
{
Expand Down

0 comments on commit 5dfd334

Please sign in to comment.