3F / DllExport

.NET DllExport with .NET Core support (aka 3F/DllExport aka DllExport.bat)
MIT License
937 stars 131 forks source link

Can I use this on a project that does not have a solution? #202

Open CoenraadS opened 2 years ago

CoenraadS commented 2 years ago

. . .

The question is related to:


Hi, I am using a project with no solution, and the GUI can't seem to handle this:

image

Is it possible?

3F commented 2 years ago

Hello,

Looks like it's not possible for current version but you can either create solution in IDE

  1. "Create a new project" - "Blank Solution"
  2. Right click - "Add" - "Existing project" - Choose .csproj, .vbproj, .fsproj etc.
  3. Save then try again.

Or generate it programmatically using MvsSln, for example, for all found .csproj something like:

string dir = @"<path to dir>\";

List<ProjectItem> projects = new();
List<IConfPlatformPrj> pcfg = new();
ConfigSln scfg = new("Debug", "arch");

foreach(string f in Directory.GetFiles(dir, "*.csproj", SearchOption.AllDirectories))
{
    string fprj = dir.MakeRelativePath(f);
    ProjectItem item = new(Path.GetDirectoryName(fprj), ProjectType.Cs, fprj);
    projects.Add(item);
    pcfg.Add(new ConfigPrj(scfg.Configuration, scfg.Platform, item.pGuid, build:true, scfg));
}

SlnHeader header = new();
header.SetFormatVersion("11.0");

save to disk

using SlnWriter w = new
(
    Path.Combine(dir, ".sln"),
    new Dictionary<Type, HandlerValue>()
    {
        [typeof(LVisualStudioVersion)] = new(new WVisualStudioVersion(header)),
        [typeof(LProject)] = new(new WProject(projects, new LProjectDependencies())),
        [typeof(LSolutionConfigurationPlatforms)] = new(new WSolutionConfigurationPlatforms(new[] { scfg })),
        [typeof(LProjectConfigurationPlatforms)] = new(new WProjectConfigurationPlatforms(pcfg)),
    }
);
w.Write(new[]
{
    new Section(new LVisualStudioVersion(), null),
    new Section(new LProject(), null),
    new Section(null, "Global"),
    new Section(new LSolutionConfigurationPlatforms(), null),
    new Section(new LProjectConfigurationPlatforms(), null),
    new Section(null, "EndGlobal"),
});

Keep issue open to consider some automatic generation in future releases.

steve02081504 commented 5 months ago

Any progress on this issue? I'm trying to get my tool to support exporting powershell functions in the dll symbol list, and I'm having problems with how to export C# functions as win32 symbols it generates C# code file and compiles it directly to .NETFramework4.7 using CodeDom, I'm not sure how to use DllExport in the generated code....

3F commented 4 weeks ago

@steve02081504

Recent MvsSln 2.7+ provides modern wrappers to create a solution from scratch in a few easy steps https://github.com/3F/MvsSln/issues/61#issuecomment-2079155362

This can now be used to create solution and project files under DllExport project and this issue.

using CodeDom, I'm not sure how to use DllExport in the generated code....

Since we're working through assembler beyond the CLR, it can be like ~

  1. Define DllExportAttribute from DllExport meta libraries to the generated methods.
  2. Save the result and generate project + solution files using MvsSln's implementation.
  3. Activate DllExport from the command line and build the final modified modules.