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

Question regarding depending on the DllExported dlls on another project #144

Closed
NickAcPT opened this issue Apr 5, 2020 · 6 comments · Fixed by #148
Closed

Question regarding depending on the DllExported dlls on another project #144

NickAcPT opened this issue Apr 5, 2020 · 6 comments · Fixed by #148

Comments

@NickAcPT
Copy link

NickAcPT commented Apr 5, 2020

So, currently, I have a .NET Core project on my solution called Hooks where I export some methods to deal with Windows Hooks. And I need to depend on that project from another project on the same solution.

Is it possible to, without using the Post build actions, make the project copy the DLLs in the x86 and x64 folders to the output directory of the projects that depend on it?

@3F
Copy link
Owner

3F commented Apr 5, 2020

without using the Post build actions

Yes. Try this https://github.com/3F/vsSolutionBuildEvent

It can especially help if, for example, you want to avoid any changes to the projects files (etc).

Scripting is available through various engines (msbuild targets, C#, or SobaScript and E-MSBuild, etc).
IDE and CI support of course.

Or you can interact more with Visual Studio on the fly via https://github.com/3F/vsCommandEvent

@NickAcPT
Copy link
Author

NickAcPT commented Apr 5, 2020

But that will require an extension to be installed.
It would be nice to have it inside DllExport somehow so that things work everywhere.

@3F
Copy link
Owner

3F commented Apr 5, 2020

But that will require an extension to be installed.

Only if you need support IDE. For CIM it's automated through nuget and does not require anything from user. This repo is also configured through CIM version.

It would be nice to have it inside DllExport somehow so that things work everywhere.

Actually we can try through https://github.com/3F/MvsSln extend support for projects that depends on project where DllExport is used. But in fact this task is not trivial and:

  • Firstly, it will be limited to just a single solution (where projects are activated for build) because we definitely can know only this and nothing concrete from outside.
  • And secondly, we need implement a decent piece of logic for managing this through project-scope. Because solution-scope is not available for build through vs/msbuild if we're talking about default user's tools/actions with projects.

You can also open PR to consider a better way together.

Thus, I recommend to use at least vsSolutionBuildEvent, or alternatives (if you do not want to use my mentioned projects for some reason)

@NickAcPT
Copy link
Author

NickAcPT commented Apr 5, 2020

Oh, I see. I'll use that for now 👍
Thanks a lot.

@NickAcPT NickAcPT closed this as completed Apr 5, 2020
@3F
Copy link
Owner

3F commented Apr 19, 2020

It would be nice to have it inside

I think we can try to review this suggestion as optional Post-Processing feature "as is" like for a new #146 where built Pre-Processing.

But as I mentioned:

  1. Default tasks such ResolveAssemblyReferences + ReferenceCopyLocalPaths (and related) will be really difficult for anything to base on it.
  2. Implementing a new or some modifications of the default logic is a big task for this really tiny thing. Let me know if msbuild provides another suitable tasks for this issue.
  3. The project itself does not know where it will be used which is logically correct for what purpose ResolveAssemblyReferences was initially designed.
  4. Historically the solution-scope did not have (and partially still hasn't) a clear specification or even public implementation in all visualstudio-family products. This is one of the reasons why MvsSln was appeared together with vsSBE in 2013.

MvsSln, however, already implements the dependency graph in analyzed solution (I know, because I was personally implementing this in the past). But as I voiced this task is complicated by the user context where both visualstudio and msbuild can provide only a separate project-or-like environment.

And if we're talking about a normal implementation from outside, then we also need to control the build state for the whole solution scope from a restricted project scope. Otherwise we cannot be sure of anything since modules or even paths can be also modified later for some reason from other tools, and so on.

But we can do it easier if we'll try only to copy our artifacts by paths from evaluated properties at the moment of processing DllExport, again, without guarantees of anything.

This is most simple solution for this issue, but it cannot be safe for all user cases as you can see. However, this is perfectly fits for some additional option for Post-Processing feature.

@3F 3F reopened this Apr 19, 2020
@3F 3F added the suggestion label Apr 19, 2020
@3F 3F added this to the 1.7.1 milestone Apr 19, 2020
@3F
Copy link
Owner

3F commented Apr 19, 2020

I'll try to review this for 1.7.1.

By the way, the use of the mentioned graph is currently complicated by this issue: 3F/MvsSln#25
Let me know if anyone knows something about related changes in Visual Studio 16.x !

3F added a commit that referenced this issue Apr 28, 2020
3F added a commit that referenced this issue Apr 30, 2020
@3F 3F closed this as completed in #148 May 7, 2020
3F added a commit that referenced this issue May 7, 2020
* MvsSln up to rev `9c39498` due to 3F/MvsSln#25

Part of #144

* Post-Processing #148: Implemented backend logic with configurable environment:

Format: $(SolutionPath);$(MSBuildThisFileFullPath);...populated property names...;....

```
<Target Name="DllExportPostProc">

    <!-- Now we can access the following properties and items:

    $(DllExport)     - version
    $(DllExportSln)  - full path to .sln which controls current project
    $(DllExportPrj)  - full path to current project where processed .NET DllExport

    @(DllExportDirX64)    - $(TargetDir)x64\*.*
    @(DllExportDirX86)    - $(TargetDir)x86\*.*
    @(DllExportDirBefore) - $(TargetDir)Before\*.*
    @(DllExportDirAfter)  - $(TargetDir)After\*.*

    @(DllExportDependents + populated property name)
       - each populated properties from DllExportInvokedPoint, e.g. DllExportDependentsTargetDir

    @(DllExportDependencies + populated property name)
      - each populated properties from DllExportInvokedPoint, e.g. DllExportDependenciesTargetDir

    -->

</Target>
```

* Post-Proc. Added support of external .net.dllexport.targets

* PostProc usage has been moved into ExportTaskImplementation

* Fixed MSB4094 when using the same properties

+Checking the existence of our entry point

* `DllExportInvokedPoint` renamed as `DllExportProcEnv`

* Basic GUI support for predefined options in Post-Proc feature

That is,

*! Some Post-Proc features are not yet available in GUI. But you can already configure it with msbuild.

* cleanup

* Updated data in SimpleConfFormater.Parse()

+PostProc +PreProc

* MvsSln up to rev `838fab00dd` /? #148 (comment)

* MvsSln up to rev `e07c5806dd`: +`ProjectReference` support without obsolete projectguid

* Updated MvsSln 2.5.2

* Added multiple destination support via derivative targets:
#148 (comment)

* +`DllExportSeqDependents...` Includes sequential referencing through other projects
3F added a commit that referenced this issue May 7, 2020
* NEW: Pre-Processing feature. PR #146.
       Related issue #40

       Official ILMerge support;
       https://github.com/dotnet/ILMerge

       Quick integration with Conari for most easy access to unmanaged features;
       https://github.com/3F/Conari

       +Other related tools and assembly manipulations.
       Manual configuring: #40 (comment)

* NEW: Post-Processing. PR #148.
       Continues direction of Pre-Processing feature. PR #146
       Related issue #144

       Explanation and details:
       https://ko-fi.com/Blog/Post/ILMerge---Conari---Debug-information---DllExport-=-O5O61MV8A

       1.7.1 Provides only basic GUI support for predefined options. Thus,

        *! Some Post-Proc features are not yet available in GUI.
        But you can already configure it with msbuild:
        ```
        <Target Name="DllExportPostProc">

            <!-- After activation, you can access the following properties and items:

            $(DllExport)     - version
            $(DllExportSln)  - full path to .sln which controls current project
            $(DllExportPrj)  - full path to current project where processed .NET DllExport

            @(DllExportDirX64)    - $(TargetDir)x64\*.*
            @(DllExportDirX86)    - $(TargetDir)x86\*.*
            @(DllExportDirBefore) - $(TargetDir)Before\*.*
            @(DllExportDirAfter)  - $(TargetDir)After\*.*

            @(DllExportDependents + populated property name)
               - each populated properties from DllExportProcEnv,
                  e.g. DllExportDependentsTargetDir

            @(DllExportDependencies + populated property name)
              - each populated properties from DllExportProcEnv,
                  e.g. DllExportDependenciesTargetDir

            @(DllExportSeqDependents + populated property name)
               - each populated properties from DllExportProcEnv,
                  e.g. DllExportSeqDependentsTargetDir

            -->

        </Target>
        ```
        #148 (comment)

* NEW: Optional copying of intermediate files + x86+x64 directories into output
           for projects that dependent on projects where used DllExport. Issue #144.

           Including sequential referencing through other projects:
           #148 (comment)

* FIXED: Fixed #140 ... failed to create safe SSL/TLS context.

* FIXED: Pack of fixes for .net.dllexport.targets. PR #147.

        * Fixed "Cannot modify an evaluated object originating in an imported file".
        * Fixed possible duplication in .net.dllexport.targets when configuring.
        * Adds removing TargetsFile if not used.
        * Fixed possible loss of settings in .targets when configuring.

* FIXED: Fixed #143 'Microsoft.NET.Sdk' specified could not be found.

* FIXED: A multiple empty `<PropertyGroup />` in project files during new configuration.

* CHANGED: Wizard. Dropped support for ssl3 + tls1.0 + tls1.1

* CHANGED: Wizard. Simplified notification for stable versions.

* CHANGED: Manager. Access to hMSBuild tool (packed) via `-hMSBuild` key.
                    https://github.com/3F/hMSBuild
                    Since it uses packed version (while GetNuTool is integrated inside),
                    you need use -dxp-version to control specific version.

* CHANGED: Updated Cecil 0.11.2
           https://github.com/jbevain/cecil/releases/tag/0.11.2

* CHANGED: Updated MvsSln 2.5.2
           https://github.com/3F/MvsSln/releases/tag/2.5.2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants