Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VS publish fails with 'Metadata generation failed' #5229

Open
TehWardy opened this issue Nov 11, 2019 · 5 comments
Open

VS publish fails with 'Metadata generation failed' #5229

TehWardy opened this issue Nov 11, 2019 · 5 comments
Assignees

Comments

@TehWardy
Copy link

I think i'm seeing something like these ...

#4055
#4578

Everything builds and runs fine locally.
Left a working deploy-able solution on Friday, came in this morning to fix something completely unrelated and it's unable to publish.

This is what my VS output window has to say about the matter ...

1>------ Build started: Project: Workflow, Configuration: Debug Any CPU ------
1>Workflow -> D:\tfs\clx\Dev\v3\Workflow\bin\Debug\netcoreapp2.2\bin\Workflow.dll
2>------ Publish started: Project: Workflow, Configuration: Debug Any CPU ------
2>Restore completed in 893.78 ms for D:\tfs\clx\Dev\v3\Core.Objects\Core.Objects.csproj.
2>Restore completed in 893.07 ms for D:\tfs\clx\Dev\v3\Workflow\Workflow.csproj.
2>Restore completed in 893.31 ms for D:\tfs\clx\Dev\v3\Core.B2B.Objects\Core.B2B.Objects.csproj.
2>C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\Roslyn\csc.exe /noconfig /unsafe- /checked- /nowarn:1701,1702,1701,1702,2008 /nostdlib+ /platform:x86 /errorreport:prompt /warn:4 /define:TRACE;DEBUG;NETCOREAPP;NETCOREAPP2_2 /errorendlocation /preferreduilang:en-US /reference: ...
2>Workflow -> D:\tfs\clx\Dev\v3\Workflow\bin\Debug\netcoreapp2.2\win-x86\bin\Workflow.dll
2>System.IO.FileLoadException: Could not load file or assembly 'Workflow, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.
2> at System.Runtime.Loader.AssemblyLoadContext.LoadFromPath(IntPtr ptrNativeAssemblyLoadContext, String ilPath, String niPath, ObjectHandleOnStack retAssembly)
2> at System.Runtime.Loader.AssemblyLoadContext.LoadFromAssemblyPath(String assemblyPath)
2> at System.Reflection.Assembly.LoadFrom(String assemblyFile)
2> at MakeFunctionJson.FunctionJsonConverter.TryGenerateFunctionJsons()
2> at MakeFunctionJson.FunctionJsonConverter.TryRun()
2>Error generating functions metadata
2>
2>Metadata generation failed.
========== Build: 1 succeeded, 0 failed, 2 up-to-date, 0 skipped ==========
========== Publish: 0 succeeded, 1 failed, 0 skipped ==========

Things I've tried ...

  • Deleted my entire local copy of the repo, and all nuget packages.
  • Flushed out VS temp files and rebooted the machine.
  • Fetched solution, built and run the azure function locally to confirm it's all good.
  • Right click > publish

I can confirm ...

  • I'm running .Net Core 2.2 latest assemblies
  • Latest .29 release of Azure Functions
  • VS2019 fully patched.
  • Problem only seems to be with the cloud deploy, everything else is fine.
@TehWardy
Copy link
Author

TehWardy commented Nov 11, 2019

Ok having created a new "copy of the project" by simply telling VS to create a new azure functions project and then importing the code from the original and changing nothing ... I found that the publish profiles have the following differences ...

The broken one has these extra elements

<MSDeployPublishMethod>WMSVC</MSDeployPublishMethod>
<_IsPortable>true</_IsPortable>
<EnableMsDeployAppOffline>True</EnableMsDeployAppOffline>
<EnableMSDeployBackup>True</EnableMSDeployBackup>
<DeployIisAppPath>CLXDev-Workflow</DeployIisAppPath>

And for the elements that they both had I notice that there was a single key difference other than urls / key information username ect ...

<WebPublishMethod>ZipDeploy</WebPublishMethod>
<WebPublishMethod>MSDeploy</WebPublishMethod>

...

It seems that MSDeploy isn't working for Azure Functions I guess.

@brettsam
Copy link
Member

Can you share what your broken project file looks like?

@TehWardy
Copy link
Author

Of course ... here it is ...

<?xml version="1.0" encoding="utf-8"?>
<!-- https://go.microsoft.com/fwlink/?LinkID=208121. -->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <WebPublishMethod>MSDeploy</WebPublishMethod>
    <PublishProvider>AzureWebSite</PublishProvider>
    <LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
    <LastUsedPlatform>Any CPU</LastUsedPlatform>
    <SiteUrlToLaunchAfterPublish>https://clxdev-workflow.azurewebsites.net</SiteUrlToLaunchAfterPublish>
    <LaunchSiteAfterPublish>False</LaunchSiteAfterPublish>
    <ResourceId>/subscriptions/{my sub id}/resourceGroups/Dev/providers/Microsoft.Web/sites/{ResourceName}</ResourceId>
    <UserName>$CLXDev-Workflow</UserName>
    <_SavePWD>True</_SavePWD>
    <ExcludeApp_Data>False</ExcludeApp_Data>
    <MSDeployServiceURL>{ResourceName}.scm.azurewebsites.net:443</MSDeployServiceURL>
    <MSDeployPublishMethod>WMSVC</MSDeployPublishMethod>
    <SkipExtraFilesOnServer>False</SkipExtraFilesOnServer>
    <EnableMsDeployAppOffline>True</EnableMsDeployAppOffline>
    <EnableMSDeployBackup>True</EnableMSDeployBackup>
    <DeployIisAppPath>{ResourceName}</DeployIisAppPath>
  </PropertyGroup>
</Project>

This file was generated by an earlier version of the tooling for VS.
I get the impression (due to a delay when I ask it to build the profile) it's trying to do the same thing even now, but for some reason that fails and so as a fallback it takes the zip route.

Is there some advantage to executing an Azure functions app directly out of a Zip package, surely that would slow execution times down having to unpack it?

@brettsam
Copy link
Member

Running from zip (or officially known as "run from package") has a lot of benefits and is the recommended way to deploy function apps. You can see here for more details: Azure/app-service-announcements#84.

Do you see any more explicit errors in the Output window in VS? You may need to change the source from the dropdown to see if there's anything useful.

@TehWardy
Copy link
Author

Nothing more than I've already given you.
To be honest since having this i figured out I could just delete the existing publish profile and resource in the cloud then:

  • Hit publish from the project context menu in the solution tree.
  • Configure a "new resource" to have it then create a new "working profile".

Not sure how to save the generated auth info though so I can check in to the azure devops repo and have pipelines use it later.

Feels overkill, but it solved the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants