Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Post-Build event no longer work as expected (if compared to UnmanagedExports)

See original GitHub issue

I have discovered this bug a while ago and I am surprised to see that it is still not fixed. Note: This bug is specific to DllExport code/package (any version)! Such bug does not exist in UnmanagedExports code/package (v1.2.7).

For example:

  1. Create a new C# class library project.
  2. Download/Install DllExport into project via NuGet (Install-Package DllExport, pick any version, the newest release v1.5.2 is still affected by this bug).
  3. Use whatever DllExport configuration options you want, it doesn’t matter at all.
  4. Go to Project -> Properties -> Build Events page.
  5. Enter (or copy/paste) the following into post-build command line: COPY /Y "$(TargetPath)" "$(SolutionDir)$(TargetFileName)"

You should have something like this: image Next, build the project and wait for it to complete. The above simple post-build event should copy the compiled DLL with exports into another directory (overwriting the existing file if it exists). However, it seems that it instead copies compiled DLL without any exports into another directory.

And like I already said, this is not the case with UnmanagedExports package; post-build event works fine with UnmanagedExports package, apparently this bug has been introduced in DllExport code/package!

To speed things up, you can download my example (DllExport) VS2017 solution from here:

And here you can also download another example VS2017 solution which uses UnmanagedExports package instead (to see that post-build works correctly with it):

Please fix DllExport 😃

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

3Fcommented, May 6, 2017

You about records from IMAGE_DATA_DIRECTORY 😃 I see, did not noticed because as I said above - it still all ok via vssbe scripts 😃

for std. VS build-events I will look later, thanks.

temporarily you can try with vssbe, or try something manually via targets.

3Fcommented, Jun 5, 2017

please check it with latest changes -

But now we can’t use Post-build events (PostBuildEvent) before processing our tool. If you need this, use something like:

<Target Name="PostBuildEventBeforeDllExport" BeforeTargets="DllExportMod">
  <Exec Command="..." ContinueOnError="true" />


Read more comments on GitHub >

github_iconTop Results From Across the Web

Why is this Visual Studio post-build event not firing?
I am trying to copy all of my output files from the solution target directory to a shared bin folder but for some...
Read more >
PostBuild event failure - Developer Community
VSF_TYPE_MARKDOWNI have a project from Visual Studio 2015 that I imported into Visual Studio 2019, and it was failing on one of the...
Read more >
Migration to .NET 7 breaks post build event
I am experiencing that my post build event does no longer work, afai can tell because multiple variables are no longer supported.
Read more >
How to Automate Exporting .NET Function to Unmanaged ...
Post-build tool which can automate exporting .NET function to unmanaged programs.
Read more >
[Solved]-C# unmanaged dll exporting (how it works)
I'll post an answer, collecting the comments I wrote. The most famous library for doing it is (as today) the UnmanagedExports.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found