USMC6072
USMC6072

Reputation: 668

Visual Studio Publish looking for dependent dll in wrong folder

I have a .Net 8 function app (DRIContactServiceUpdate) and a web app (DRIContactManagement) in a single solution. The function app is dependent on the web app. Everything runs fine when I run the function app on my local machine. I'm trying to publish the function app to Azure, it builds but fails during Publish for C:\Users\Chris\source\repos\DRIContactManagement\DRIContactManagement\obj\Release\net8.0\win-x64\ref\DRIContactManagement.dll' could not be found The problem is, win-x64\ref doesn't exist. I found where the build was copying the dependent file to the function app as I expect:

Copying file from "C:\Users\Chris\source\repos\DRIContactManagement\DRIContactManagement\bin\x64\Release\net8.0\DRIContactManagement.dll" to "C:\Users\Chris\source\repos\DRIContactManagement\DRIServiceUpdate\bin\x64\Release\net8.0\DRIContactManagement.dll".

The only place I find win-x64 referenced is in the Publish settings but I can't find a path defined referencing that folder.

enter image description here

I've tried all the typical solutions:

  1. Clean and Build
  2. Delete the bin and obj folders in both projects and rebuild
  3. Restarted Visual Studio
  4. Remove the project dependency and re-add it.

I can't find anything online quite like this but I'm sure it's not unique. Any suggestions?

Upvotes: 1

Views: 458

Answers (3)

Magnus
Magnus

Reputation: 1

Without the minimal reproducible example it is hard to investigate too deeply on my own, but two major things I would look at:

  1. The build process is copying the DLL from bin\x64\Release\net8.0, but the publish process is looking for it in win-x64\ref. I would double check to see which one you are intending it to be in and try changing the path; it is usually somewhere like <solution-root>\bin\x64\Release\net8.0\.

  2. Have you tried manually copying the DLLs from the bin\Release\net8.0 directory of DRIContactManagement to the corresponding directory in DRIServiceUpdate? This only a temporary fix but will help to see if the problem is in the build or publish steps.

Upvotes: -1

Jhonty
Jhonty

Reputation: 303

Please share your .pubxml file details.

<!-- Ensure RuntimeIdentifier is not set or empty for portable deployment -->
    <RuntimeIdentifier></RuntimeIdentifier>

The tag mentioned here should be empty if not it needs to be set to empty.

When I set the tag value to empty RuntimeIdentifier tag

It gives me this result in publish settings: Publish settings

By ensuring the is empty or not set in the .pubxml file, you configure the application to be published without targeting a specific runtime, thus making it portable.

Upvotes: 1

USMC6072
USMC6072

Reputation: 668

After a lot of searching I found this discussion: https://developercommunity.visualstudio.com/t/clickonce-publish-metadata-file-could-not-be-found/1430499

I still don't know what is causing the issue but the work-around is to switch the publish profile's Target Runtime to "Portable".

Upvotes: 2

Related Questions