Error publishing simple DLL on .NET Core 3.1
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! ✌
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
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.
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
IsPackable switch indeed disabled the generation of the NuGet package but now nothing gets published, not a single file :-/
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
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.
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.
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
Sorry my mistake. I have corrected. However, will not publish with that setting either.
@cabbytech what error? or better to look log or .csproj file
make sure this was not redefined by other DebugType/DebugSymbols properties
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 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
Is this closed by now?