0

I have a .net core 3.1 worker service used as a windows service. The self contained publish fails in visual studio 2019. enter image description here

Output:

1>------ Publish started: Project: RineService, Configuration: Release Any CPU ------
1>Detected package downgrade: System.Runtime.InteropServices from 4.3.0 to 4.1.0. Reference the package directly from the project to select a different version. 
1> RineService -> log4net 2.0.8 -> System.Console 4.0.0 -> runtime.win.System.Console 4.3.0 -> System.Runtime.InteropServices (>= 4.3.0) 
1> RineService -> log4net 2.0.8 -> System.Runtime.InteropServices (>= 4.1.0)
1>Detected package downgrade: System.Threading from 4.3.0 to 4.0.11. Reference the package directly from the project to select a different version. 
1> RineService -> log4net 2.0.8 -> System.Console 4.0.0 -> runtime.win.System.Console 4.3.0 -> System.Threading (>= 4.3.0) 
1> RineService -> log4net 2.0.8 -> System.Threading (>= 4.0.11)
1>Detected package downgrade: System.Diagnostics.Debug from 4.3.0 to 4.0.11. Reference the package directly from the project to select a different version. 
1> RineService -> log4net 2.0.8 -> System.IO.FileSystem 4.0.1 -> runtime.win.System.IO.FileSystem 4.3.0 -> System.Diagnostics.Debug (>= 4.3.0) 
1> RineService -> log4net 2.0.8 -> System.Diagnostics.Debug (>= 4.0.11)
1>Detected package downgrade: System.Runtime.Extensions from 4.3.0 to 4.1.0. Reference the package directly from the project to select a different version. 
1> RineService -> log4net 2.0.8 -> System.IO.FileSystem 4.0.1 -> runtime.win.System.IO.FileSystem 4.3.0 -> System.Runtime.Extensions (>= 4.3.0) 
1> RineService -> log4net 2.0.8 -> System.Runtime.Extensions (>= 4.1.0)
1>Detected package downgrade: System.Runtime.InteropServices from 4.3.0 to 4.1.0. Reference the package directly from the project to select a different version. 
1> RineService -> log4net 2.0.8 -> System.IO.FileSystem 4.0.1 -> runtime.win.System.IO.FileSystem 4.3.0 -> System.Runtime.InteropServices (>= 4.3.0) 
1> RineService -> log4net 2.0.8 -> System.Runtime.InteropServices (>= 4.1.0)
1>Detected package downgrade: System.Threading from 4.3.0 to 4.0.11. Reference the package directly from the project to select a different version. 
1> RineService -> log4net 2.0.8 -> System.IO.FileSystem 4.0.1 -> runtime.win.System.IO.FileSystem 4.3.0 -> System.Threading (>= 4.3.0) 
1> RineService -> log4net 2.0.8 -> System.Threading (>= 4.0.11)
1>Detected package downgrade: System.Diagnostics.Debug from 4.3.0 to 4.0.11. Reference the package directly from the project to select a different version. 
1> RineService -> log4net 2.0.8 -> System.Net.Sockets 4.1.0 -> runtime.win.System.Net.Sockets 4.3.0 -> System.Diagnostics.Debug (>= 4.3.0) 
1> RineService -> log4net 2.0.8 -> System.Diagnostics.Debug (>= 4.0.11)
1>Detected package downgrade: System.IO.FileSystem from 4.3.0 to 4.0.1. Reference the package directly from the project to select a different version. 
1> RineService -> log4net 2.0.8 -> System.Net.Sockets 4.1.0 -> runtime.win.System.Net.Sockets 4.3.0 -> System.IO.FileSystem (>= 4.3.0) 
1> RineService -> log4net 2.0.8 -> System.IO.FileSystem (>= 4.0.1)
1>Detected package downgrade: System.Net.NameResolution from 4.3.0 to 4.0.0. Reference the package directly from the project to select a different version. 
1> RineService -> log4net 2.0.8 -> System.Net.Sockets 4.1.0 -> runtime.win.System.Net.Sockets 4.3.0 -> System.Net.NameResolution (>= 4.3.0) 
1> RineService -> log4net 2.0.8 -> System.Net.NameResolution (>= 4.0.0)
1>Detected package downgrade: System.Net.Primitives from 4.3.0 to 4.0.11. Reference the package directly from the project to select a different version. 
1> RineService -> log4net 2.0.8 -> System.Net.Sockets 4.1.0 -> runtime.win.System.Net.Sockets 4.3.0 -> System.Net.Primitives (>= 4.3.0) 
1> RineService -> log4net 2.0.8 -> System.Net.Sockets 4.1.0 -> System.Net.Primitives (>= 4.0.11)
1>Detected package downgrade: System.Runtime.Extensions from 4.3.0 to 4.1.0. Reference the package directly from the project to select a different version. 
1> RineService -> log4net 2.0.8 -> System.Net.Sockets 4.1.0 -> runtime.win.System.Net.Sockets 4.3.0 -> System.Runtime.Extensions (>= 4.3.0) 
1> RineService -> log4net 2.0.8 -> System.Runtime.Extensions (>= 4.1.0)
1>Detected package downgrade: System.Runtime.InteropServices from 4.3.0 to 4.1.0. Reference the package directly from the project to select a different version. 
1> RineService -> log4net 2.0.8 -> System.Net.Sockets 4.1.0 -> runtime.win.System.Net.Sockets 4.3.0 -> System.Runtime.InteropServices (>= 4.3.0) 
1> RineService -> log4net 2.0.8 -> System.Runtime.InteropServices (>= 4.1.0)
1>Detected package downgrade: System.Threading from 4.3.0 to 4.0.11. Reference the package directly from the project to select a different version. 
1> RineService -> log4net 2.0.8 -> System.Net.Sockets 4.1.0 -> runtime.win.System.Net.Sockets 4.3.0 -> System.Threading (>= 4.3.0) 
1> RineService -> log4net 2.0.8 -> System.Threading (>= 4.0.11)
1>Detected package downgrade: System.Runtime.InteropServices from 4.3.0 to 4.1.0. Reference the package directly from the project to select a different version. 
1> RineService -> log4net 2.0.8 -> System.Diagnostics.Process 4.1.0 -> Microsoft.Win32.Primitives 4.0.1 -> runtime.win.Microsoft.Win32.Primitives 4.3.0 -> System.Runtime.InteropServices (>= 4.3.0) 
1> RineService -> log4net 2.0.8 -> System.Runtime.InteropServices (>= 4.1.0)
1>Detected package downgrade: System.Runtime.InteropServices from 4.3.0 to 4.1.0. Reference the package directly from the project to select a different version. 
1> RineService -> log4net 2.0.8 -> System.IO.FileSystem.Watcher 4.0.0 -> Microsoft.Win32.Primitives 4.0.1 -> runtime.win.Microsoft.Win32.Primitives 4.3.0 -> System.Runtime.InteropServices (>= 4.3.0) 
1> RineService -> log4net 2.0.8 -> System.Runtime.InteropServices (>= 4.1.0)
1>Detected package downgrade: System.Runtime.Extensions from 4.3.0 to 4.1.0. Reference the package directly from the project to select a different version. 
1> RineService -> log4net 2.0.8 -> System.Net.NameResolution 4.0.0 -> System.Net.Primitives 4.0.11 -> runtime.win.System.Net.Primitives 4.3.0 -> System.Runtime.Extensions (>= 4.3.0) 
1> RineService -> log4net 2.0.8 -> System.Runtime.Extensions (>= 4.1.0)
1>Detected package downgrade: System.Runtime.InteropServices from 4.3.0 to 4.1.0. Reference the package directly from the project to select a different version. 
1> RineService -> log4net 2.0.8 -> System.Net.NameResolution 4.0.0 -> System.Net.Primitives 4.0.11 -> runtime.win.System.Net.Primitives 4.3.0 -> System.Runtime.InteropServices (>= 4.3.0) 
1> RineService -> log4net 2.0.8 -> System.Runtime.InteropServices (>= 4.1.0)
1>Detected package downgrade: System.Threading from 4.3.0 to 4.0.11. Reference the package directly from the project to select a different version. 
1> RineService -> log4net 2.0.8 -> System.Net.NameResolution 4.0.0 -> System.Net.Primitives 4.0.11 -> runtime.win.System.Net.Primitives 4.3.0 -> System.Threading (>= 4.3.0) 
1> RineService -> log4net 2.0.8 -> System.Threading (>= 4.0.11)
1>Detected package downgrade: System.Runtime.Extensions from 4.3.0 to 4.1.0. Reference the package directly from the project to select a different version. 
1> RineService -> log4net 2.0.8 -> System.Net.Requests 4.0.11 -> System.Net.Primitives 4.0.11 -> runtime.win.System.Net.Primitives 4.3.0 -> System.Runtime.Extensions (>= 4.3.0) 
1> RineService -> log4net 2.0.8 -> System.Runtime.Extensions (>= 4.1.0)
1>Detected package downgrade: System.Runtime.InteropServices from 4.3.0 to 4.1.0. Reference the package directly from the project to select a different version. 
1> RineService -> log4net 2.0.8 -> System.Net.Requests 4.0.11 -> System.Net.Primitives 4.0.11 -> runtime.win.System.Net.Primitives 4.3.0 -> System.Runtime.InteropServices (>= 4.3.0) 
1> RineService -> log4net 2.0.8 -> System.Runtime.InteropServices (>= 4.1.0)
1>Detected package downgrade: System.Threading from 4.3.0 to 4.0.11. Reference the package directly from the project to select a different version. 
1> RineService -> log4net 2.0.8 -> System.Net.Requests 4.0.11 -> System.Net.Primitives 4.0.11 -> runtime.win.System.Net.Primitives 4.3.0 -> System.Threading (>= 4.3.0) 
1> RineService -> log4net 2.0.8 -> System.Threading (>= 4.0.11)
1>Detected package downgrade: System.Runtime.Extensions from 4.3.0 to 4.1.0. Reference the package directly from the project to select a different version. 
1> RineService -> log4net 2.0.8 -> System.Net.Sockets 4.1.0 -> System.Net.Primitives 4.0.11 -> runtime.win.System.Net.Primitives 4.3.0 -> System.Runtime.Extensions (>= 4.3.0) 
1> RineService -> log4net 2.0.8 -> System.Runtime.Extensions (>= 4.1.0)
1>Detected package downgrade: System.Runtime.InteropServices from 4.3.0 to 4.1.0. Reference the package directly from the project to select a different version. 
1> RineService -> log4net 2.0.8 -> System.Net.Sockets 4.1.0 -> System.Net.Primitives 4.0.11 -> runtime.win.System.Net.Primitives 4.3.0 -> System.Runtime.InteropServices (>= 4.3.0) 
1> RineService -> log4net 2.0.8 -> System.Runtime.InteropServices (>= 4.1.0)
1>Detected package downgrade: System.Threading from 4.3.0 to 4.0.11. Reference the package directly from the project to select a different version. 
1> RineService -> log4net 2.0.8 -> System.Net.Sockets 4.1.0 -> System.Net.Primitives 4.0.11 -> runtime.win.System.Net.Primitives 4.3.0 -> System.Threading (>= 4.3.0) 
1> RineService -> log4net 2.0.8 -> System.Threading (>= 4.0.11)
1>Detected package downgrade: System.Runtime.InteropServices from 4.3.0 to 4.1.0. Reference the package directly from the project to select a different version. 
1> RineService -> log4net 2.0.8 -> System.Net.NameResolution 4.0.0 -> System.Security.Principal.Windows 4.0.0 -> Microsoft.Win32.Primitives 4.0.1 -> runtime.win.Microsoft.Win32.Primitives 4.3.0 -> System.Runtime.InteropServices (>= 4.3.0) 
1> RineService -> log4net 2.0.8 -> System.Runtime.InteropServices (>= 4.1.0)
1>Restore failed in 276.28 ms for C:\Users\Sadaqat.razzak1\Downloads\RineService (4)\RineService\RineService\RineService.csproj.
========== Build: 0 succeeded, 0 failed, 1 up-to-date, 0 skipped ==========
========== Publish: 0 succeeded, 1 failed, 0 skipped ==========
Dragon
  • 1,078
  • 2
  • 9
  • 31

2 Answers2

1

You should consolidate versions of packages. If it does not help then 1. Turn off Visual Studio 2. Clean bin and obj folders 3. Turn on Visual Studio If this still not work then try to restore, build and run the project from the command line interface without visual studio

  • already tried this even from a different system, nothing worked. Except consolidate versions , can you guide a little about this one? – Dragon May 14 '20 at 13:32
  • Have you consolidate your packages - all to one version? – Eryk Korzeniowski May 14 '20 at 13:35
  • I didn't , but I just removed the log4net lib and it worked fine , sure there is some mismatch in package versions , can you please guide is there any tool for this consolidation or I have to manually do this for every lib. – Dragon May 14 '20 at 13:55
  • Yes, sure. When you right-click on the solution file in the Visual Studio you should see on the list "Manage Nuget Packages". After that, you should have "Consolidate", nearby "Updates" – Eryk Korzeniowski May 14 '20 at 14:10
0

If you are using Visual Studio 2022 and you reference another project with similar file names, VS2022 does not accept files with same name in 2 or more project. You must solve it like this:

Publish error: Found multiple publish output files with the same relative path

Andrei Dobrin
  • 1,164
  • 4
  • 19
  • 35