Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The SolutionDir property is different from the MSBuild output #148

Merged
merged 2 commits into from
Oct 29, 2020
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
6 changes: 3 additions & 3 deletions src/Buildalyzer/ProjectAnalyzer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,12 @@ internal ProjectAnalyzer(AnalyzerManager manager, string projectFilePath, Projec
ProjectFile = new ProjectFile(projectFilePath);
EnvironmentFactory = new EnvironmentFactory(Manager, ProjectFile);
ProjectInSolution = projectInSolution;
SolutionDirectory = string.IsNullOrEmpty(manager.SolutionFilePath)
? Path.GetDirectoryName(projectFilePath) : Path.GetDirectoryName(manager.SolutionFilePath);
SolutionDirectory = (string.IsNullOrEmpty(manager.SolutionFilePath)
? Path.GetDirectoryName(projectFilePath) : Path.GetDirectoryName(manager.SolutionFilePath)) + Path.DirectorySeparatorChar;

// Get (or create) a project GUID
ProjectGuid = projectInSolution == null
? GuidUtility.Create(GuidUtility.UrlNamespace, ProjectFile.Path.Substring(SolutionDirectory.Length))
? GuidUtility.Create(GuidUtility.UrlNamespace, ProjectFile.Path.Substring(SolutionDirectory.Length - 1))
: Guid.Parse(projectInSolution.ProjectGuid);

// Set the solution directory global property
Expand Down
10 changes: 10 additions & 0 deletions tests/Buildalyzer.Tests/Integration/SimpleProjectsFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,16 @@ public void MultiTargetingBuildAllTargetFrameworksGetsSourceFiles()
}.ShouldBeSubsetOf(results["netstandard2.0"].SourceFiles.Select(x => Path.GetFileName(x).Split('.').TakeLast(2).First()), log.ToString());
}

[Test]
public void SolutionDirShouldEndWithDirectorySeparator()
{
// Given
StringWriter log = new StringWriter();
IProjectAnalyzer analyzer = GetProjectAnalyzer(@"SdkMultiTargetingProject\SdkMultiTargetingProject.csproj", log);

analyzer.SolutionDirectory.ShouldEndWith(Path.DirectorySeparatorChar.ToString());
}

[Test]
public void MultiTargetingBuildFrameworkTargetFrameworkGetsSourceFiles()
{
Expand Down