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

CSharp project configuration name ignored #359

Open
DDev101 opened this issue Apr 22, 2024 · 0 comments
Open

CSharp project configuration name ignored #359

DDev101 opened this issue Apr 22, 2024 · 0 comments

Comments

@DDev101
Copy link

DDev101 commented Apr 22, 2024

Hello! I'm unsure if this is a bug or something I'm doing incorrectly.

I'm unable to get the .csproj to generate the project configuration to match the .sln configurations.

Here is the example I created that produces the issue:

using Sharpmake;
using System.Reflection;
using System.Text.Json;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System;

[Fragment, Flags]
public enum ErrorFlag
{
    First = 1,
    Second = 2
}

public class ErrorTarget : ITarget
{
    public DevEnv DevEnv;
    public Platform Platform;
    public Optimization Optimization;
    public DotNetFramework Framework;
    public BuildSystem BuildSystem;
    public ErrorFlag ErrorFlag;
}

[Generate]
public class ErrorProject : CSharpProject
{
    public ErrorProject() : base(typeof(ErrorTarget))
    {
        AddTargets(new ErrorTarget
        {
            DevEnv = DevEnv.vs2022,
            Platform = Platform.win64,
            Optimization = Optimization.Debug | Optimization.Release | Optimization.Retail,
            Framework = DotNetFramework.net6_0,
            BuildSystem = BuildSystem.MSBuild,
            ErrorFlag = ErrorFlag.First | ErrorFlag.Second
        });

        RootPath = @Path.Combine("[project.SharpmakeCsPath]");
        SourceRootPath = @Path.Combine("[project.SharpmakeCsPath]");
    }

    [Configure]
    public void Configure(Project.Configuration conf, ErrorTarget target)
    {
        conf.Name = "[target.Platform]_[target.Optimization]_[target.ErrorFlag]";
        conf.TargetPath = "[project.SharpmakeCsPath]/generated";
    }
};

[Generate]
public class DemoSolution : Solution
{
    public DemoSolution() : base(typeof(ErrorTarget))
    {
        AddTargets(new ErrorTarget
        {
            DevEnv = DevEnv.vs2022,
            Platform = Platform.win64,
            Optimization = Optimization.Debug | Optimization.Release | Optimization.Retail,
            Framework = DotNetFramework.net6_0,
            BuildSystem = BuildSystem.MSBuild,
            ErrorFlag = ErrorFlag.First | ErrorFlag.Second
        });
    }

    [Configure]
    public void Configure(Solution.Configuration conf, ErrorTarget target)
    {
        conf.Name = "[target.Platform]_[target.Optimization]_[target.ErrorFlag]";
        conf.SolutionPath = Path.Combine("generated", "[target.DevEnv]");
        conf.AddProject<ErrorProject>(target);
    }
}

public static class Main
{
    [Sharpmake.Main]
    public static void SharpmakeMain(Arguments arguments)
    {
        KitsRootPaths.SetUseKitsRootForDevEnv(DevEnv.vs2022, KitsRootEnum.KitsRoot10, Options.Vc.General.WindowsTargetPlatformVersion.Latest);

        // Generate solutions
        arguments.Generate(typeof(DemoSolution));
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant