DllExport icon indicating copy to clipboard operation
DllExport copied to clipboard

Error publishing simple DLL on .NET Core 3.1

Open supermartzin opened this issue 5 years ago • 13 comments

Steps to reproduce:

  • Create simple Class library project targeted for .NET Core 3.1
  • Add the latest DllExport package via NuGet (configure via #175 at the time of writing this)
  • Build the project (successful)
  • Try to publish the project for either combination of platforms and you get the error

  • DllExport version: v1.7.3.58831+9a4bc51
  • Used Visual Studio 2019 v16.8.2
  • Target platform: x86
  • Runtime identifier: win-x86

Information from VS Output log:

Build started...
1>------ Build started: Project: DllExportTest, Configuration: Release x86 ------
1>DllExportTest -> [...]\DllExportTest\bin\x86\Release\netcoreapp3.1\win-x86\DllExportTest.dll
2>------ Publish started: Project: DllExportTest, Configuration: Release x86 ------
2>Determining projects to restore...
2>Restored [...]\DllExportTest\DllExportTest.csproj (in 291 ms).
2>DllExportTest -> [...]\DllExportTest\bin\x86\Release\netcoreapp3.1\win-x86\DllExportTest.dll
2>The file '[...]\DllExportTest\bin\x86\Release\netcoreapp3.1\win-x86\DllExportTest.pdb' to be packed was not found on disk.
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
========== Publish: 0 succeeded, 1 failed, 0 skipped ==========

Project builds without any issue but publish fails every time, tried also changing parameters with no luck.

Demo Project files: DllExportTest.zip

Thanks for help! ✌

supermartzin avatar Dec 08 '20 10:12 supermartzin

Thanks for the report!

Temporarily try the following (netstandard & netcoreapp targets only)

    <DebugType>embedded</DebugType>
    <DebugSymbols>true</DebugSymbols>

or

    <DebugType>none</DebugType>
    <DebugSymbols>false</DebugSymbols>

or related settings in project properties using VS IDE

3F avatar Dec 08 '20 14:12 3F

Thanks for the temp solution, seems that if you set DebugSymbols to true, you don't need to specify the DebugType element. On the other hand, when DebugSymbols are set to false or not present, you have to specify the DebugType.

Now the publishing works, but even with library OutputType, I keep getting .nupkg file as a result of publishing instead of .dll file and all the references. But I suspect that's another problem not related to this.

supermartzin avatar Dec 09 '20 14:12 supermartzin

Make sure CopyLocalLockFileAssemblies property is not a true.

If only some specific, then below:

Element attr/tag=value
PackageReference ExcludeAssets="runtime" (ie. only at build time)
ProjectReference Private="False"
Reference Private="False"

To disable generation of the NuGet packages try the following below;

When Publish

<IsPackable>False</IsPackable>

When Build

<GeneratePackageOnBuild>False</GeneratePackageOnBuild>

You can also use https://github.com/3F/vsSolutionBuildEvent for other custom scripts (public/private) and much more besides or together with msbuild

3F avatar Dec 09 '20 16:12 3F

IsPackable switch indeed disabled the generation of the NuGet package but now nothing gets published, not a single file :-/

supermartzin avatar Dec 09 '20 17:12 supermartzin

Unfortunately there is no unified solution at this day.

'embedded' for some reason or 'none' ... I don't want either implement some option for this case or forcefully remove pdb Because first of all we need to review this issue https://github.com/3F/coreclr/issues/3

Keep it open for the future fixes!

I remind everyone,

  • This affects only .NET Core based projects.
  • Temp solution is https://github.com/3F/DllExport/issues/176#issuecomment-740658460

Thanks

3F avatar Dec 28 '20 15:12 3F

IsPackable switch indeed disabled the generation of the NuGet package but now nothing gets published, not a single file :-/

Strange, it must generate a modified assembly. This however is another issue. Please open it as question if you want to discuss some solution.

3F avatar Dec 28 '20 15:12 3F

I had similar problem. Winforms targeting 3.1 Single File option would not publish but would with Single File un checked. Tried the solution

<DebugType>embedded</DebugType>
<DebugSymbols>true</DebugSymbols>

Resulted in whole project being unloaded! Coud not re-load until I removed the above.

cabbytech avatar Jan 20 '21 11:01 cabbytech

Resulted in whole project being unloaded! Coud not re-load until I removed the above.

@cabbytech msbuild properties must be declared into PropertyGroup nodes. Did you? You can simply add a new one into parent Project node or use any available.

Also I remind this can be configured inside Visual Studio IDE using project properties menu - Build - Advanced

3F avatar Jan 20 '21 13:01 3F

Sorry my mistake. I have corrected. However, will not publish with that setting either.

cabbytech avatar Jan 20 '21 13:01 cabbytech

@cabbytech what error? or better to look log or .csproj file

make sure this was not redefined by other DebugType/DebugSymbols properties

3F avatar Jan 20 '21 13:01 3F

Nothing of value in the log file but output window:

  System.ArgumentException: Invalid input specification: Found multiple entries with the same BundleRelativePath
  at Microsoft.NET.HostModel.Bundle.Bundler.GenerateBundle(IReadOnlyList`1 fileSpecs)

cabbytech avatar Jan 20 '21 13:01 cabbytech

@cabbytech It's unclear at all. Please use /v:diag or better /bl. Note the /bl by default collects the source text of project files. See Doc

3F avatar Jan 20 '21 14:01 3F

Is this closed by now?

CodingMadness avatar Jan 12 '22 14:01 CodingMadness