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

First time package restore - DllExport is not performed #159

Closed
tapika opened this issue Jun 6, 2020 · 6 comments · Fixed by #160
Closed

First time package restore - DllExport is not performed #159

tapika opened this issue Jun 6, 2020 · 6 comments · Fixed by #160
Labels
Milestone

Comments

@tapika
Copy link

tapika commented Jun 6, 2020

By briefly testing DllExport functionality - I've understood that integration into solution is not so standard mechanism - instead of nuget package restore project itself executes DllExport.bat -action Restore in $(SolutionDir)-directory.

During first restore + compilation however - the used dll becomes normal dll, without processing DllExport-attributes and it's not valid by itself. (This can be checked for example using Dependencies utility)

For second, etc problem disappears - as all required dll's from nuget package are downloaded and processed by Visual studio. This might require solution close / re-open step to make compilation process and intellisense fully functional.

I've tried to solve this, and removed from project

  <Target Name="DllExportRestorePkg" BeforeTargets="PrepareForBuild">

xml tag completely, but kept our own nuget package restore.

DllExport.bat besides restoring nuget package also generates some of dynamic dlls, which will come into DllExport.1.7.1\gcache, which are project specific dlls.

I've put into version control DllExport.1.7.1\gcache, also following files:

- tools\net.r_eg.DllExport.targets
- tools\RGiesecke.DllExport.dll
- tools\RGiesecke.DllExport.MSBuild.dll

Rest of files will be restored by nuget package restore functionality.

and after that even first compilation works correctly.

But with this fix - even first compilation start to work - I suspect msbuild is loading .dlls earlier than you expect - maybe needs to be fixed ?

@tapika tapika added the question label Jun 6, 2020
@3F
Copy link
Owner

3F commented Jun 6, 2020

This might require solution close / re-open step to make compilation

This is only for old non Sdk-style projects. Modern VS environment processes everything at runtime (EnvDTE) due to construction through intermediate or obj files.

Well, I think I understood the problem.

In 2017 it was resolved as #62 (comment)
And more like it was broken for new releases.

Can you check with latest 1.6.x release ? I will look into later. Thanks for the report!

Logically temp solution: execute -action Restore before build if no restored packages in folder.

@3F
Copy link
Owner

3F commented Jun 7, 2020

Confirmed. The problem because of unevaluated property $(DllExportMetaXBase) in the first phase. Broken in 1.7.

@3F
Copy link
Owner

3F commented Jun 7, 2020

@3F
Copy link
Owner

3F commented Jun 12, 2020

#160 (comment)

Planned for 1.7.3

3F added a commit that referenced this issue Jun 12, 2020
* FIXED: Fixed syntax error at token '-' in: IL_002d: ldc.r8 -nan(ind) with "return Double.NaN"
         Through "Single + Double NaN token patching" option. Issue #158.
            ```
            .field = float32(-nan(ind)) -> 0xFFC00000
            .field = float64(-nan(ind)) -> 0xFFF8000000000000

            ldc.r8 -nan(ind) -> 00 00 00 00 00 00 F8 FF
            ldc.r4 -nan(ind) -> 00 00 C0 FF
            ```

* FIXED: NuGet packages are not visible as installed when DLLExport enabled for project.
         Issue #152.

* FIXED: Concurrency Issue with Parallel Project Builds. Issue #73.

* FIXED: Fixed the first phase of the build when restoring. Related issue #159.

* FIXED: Fixed VS NuGet PM possible error:
         "You cannot call a method on a null-valued expression."

* CHANGED: Improves package integration. PR  #161.
            - Updated logic for packages through `-pkg-link` key.
            - Removed `-force` key from the project files
              if it was pushed together with other commands for manager.
@tapika
Copy link
Author

tapika commented Jun 14, 2020

Tested. Restore seems to be now working, but Visual studio intellisense on [DllExport] attribute starts to work only after you unload / re-load project. (Restore works thus)

But I guess to be able to restore DllExport - you need to cherry pick DllExport.bat into your own repository and save it there.

Btw, I have some multiple solutions, which are in different folders, which use same project.
It would be better to use $(ProjectDir)..\<as many upper references as needed>\.. instead of $(SolutionDir) - otherwise saving / loading configuration always require manual modification.

Btw, if anyone wishes to use cmake for generating project, it's possible to use
set_target_properties(project PROPERTIES VS_USER_PROPS .net.dllexport.targets)

but <PropertyGroup in first xml tag should not have condition.
cmake in overall is bit difficult to configure what comes to custom xml tags.

@3F
Copy link
Owner

3F commented Jun 14, 2020

Tested. Restore seems to be now working, but Visual studio intellisense on [DllExport] attribute starts to work only after you unload / re-load project. (Restore works thus)

Please use modern Sdk-style. Then it will be auto re-loaded at runtime. Or consider click on reload button in VS File Modification Detected dialog for legacy project files (non-sdk based): https://youtu.be/okPThdWDZMM?t=96

But I guess to be able to restore DllExport - you need to cherry pick DllExport.bat into your own repository and save it there.

Yes, repo must contain at least DllExport.bat (~20 Kbytes) before build. But nothing else.

$(ProjectDir)..<as many upper references as needed>..

I think you can try to open PR for providing some common solution with custom paths.

For cmake and related automation you can consider an available External storage + Export / Recover / https://github.com/3F/DllExport/wiki/DllExport-Manager#external-storage

Related issue: #76 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants