azurevisual-studio-2017azure-functionsvisual-studio-publish

Azure Function fails to publish with 'PackageDependencyResolution.targets' error


Not sure how to fix this, but I received this error when tryig to publish one of my azure functions.

FYI - I have the project set to .Net 4.6.2, as well as the other projects that have dependencies. The project builds but just doesn't publish

Should I restore all NuGet packages or is there something else I can try!?

Here is the error -

C:\Program Files\dotnet\sdk\2.1.202\Sdks\Microsoft.NET.Sdk\build\Microsoft.PackageDependencyResolution.targets(167,5): error : Assets file 'C:\Users\chuckdawit\Source\Workspaces\YogaBandy2017\YogaBandy2017\Yogabandy2017.StripeWebhook\obj\project.assets.json' doesn't have a target for '.NETFramework,Version=v4.6.1'. Ensure that restore has run and that you have included 'net461' in the TargetFrameworks for your project. [C:\Users\chuckdawit\Source\Workspaces\YogaBandy2017\YogaBandy2017\Yogabandy2017.StripeWebhook\Yogabandy2017.StripeWebhook.csproj]


Solution

  • I would recommend trying the following steps:

    1. Try deleting the bin and obj folders in project and rebuild.
    2. Opening the 'Publish' Page, then open the 'Configure' dialog, then resave. It probably just sorts the tags.
    3. Go to publish profile file(Properties/PublishProfiles/*.pubxml) and check that the TargetFramework has been updated to reflect the new framework. If not, Change manually in here or simply run through the configure option on the publish tab.

    There is a discussion about similar issue at length here.