Skip to content

Build fails because of backward slash in the ProjectDirectory #105

@Arnab-Developer

Description

@Arnab-Developer

Problem

When I clone this repo and try to run the sample app, I got a build error.

Image

Root cause

I opened the generated class and found backward slash in the ProjectDirectory.

/// <summary>
/// Returns the project directory.
/// </summary>
/// <remarks>Value is: C:\repos\BuildInformation\LinkDotNet.BuildInformation.Sample\</remarks>
public const string ProjectDirectory = "C:\repos\BuildInformation\LinkDotNet.BuildInformation.Sample\";

C# does not allow backward slash in string. That is why the build process failed. Since I am using windows and that is why this problem happened.

Proposed solution

We need to replace the backward slash with a forward slash in the ProjectDirectory.

return !analyzer.GlobalOptions.TryGetValue("build_property.projectDir", out var projectDir)
    ? string.Empty
    : projectDir.Replace('\\', '/');

It should work for both windows and linux os.

You can check the fix here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions