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

dotnet pack fails with Could not evaluate 'Microsoft.CSharp.dll' for extension metadata. Exception message: Could not load file or assembly 'Microsoft.CSharp, Version=4.0.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. #4856

Closed
JonasSamuelsson opened this issue Aug 28, 2019 · 2 comments

Comments

@JonasSamuelsson
Copy link

I can't pack a project that has a dependency on Microsoft.NET.Sdk.Functions 1.0.29, the exact command and output can be found in the details section below.

I don't get an actual error but the output folder is empty. I also get the same error on dotnet build and `dotnet

I'm getting the following warning C:\Users\jonas\.nuget\packages\microsoft.azure.webjobs.script.extensionsmetadatagenerator\1.1.2\build\Microsoft.Azure.WebJobs.Script.ExtensionsMetadataGenerator.targets(52,5): warning : Could not evaluate 'Microsoft.CSharp.dll' for extension metadata. Exception message: Could not load file or assembly 'Microsoft.CSharp, Version=4.0.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. and guessing that it is why it doesn't work

.

Seems related to #4055 and as requested by @brettsam I've emailed him the binlog.

The code can be found at https://github.com/JonasSamuelsson/Handyman/tree/957ad85ea139cd8e6c37fce69046851cb4388d62/src/Handyman.Azure.Functions
The error occurs both locally and in devops, https://dev.azure.com/jonassamuelsson/Handyman/_build/results?buildId=193&view=results

powershell:

dotnet pack --no-restore --no-build -c release -o ./.artifacts --include-symbols -p:SymbolPackageFormat=snupkg C:\dev\GitHub\Handyman\src\Handyman.Azure.Functions\build/../src/Handyman.Azure.Functions.csproj /bl
Microsoft (R) Build Engine version 16.2.32702+c4012a063 for .NET Core 
Copyright (C) Microsoft Corporation. All rights reserved.

C:\Program Files\dotnet\sdk\2.2.401\MSBuild.dll -distributedlogger:Microsoft.DotNet.Tools.MSBuild.MSBuildLogger,C:\Program Files\dotnet\sdk\2.2.401\dotnet.dll*Microsoft.DotNet.Tools.MSBuild.MSBuildForwardingLogger,C:\Program Files\dotnet\sdk\2.2.401\dotnet.dll -maxcpucount -property:NoBuild=true -property:Configuration=release -property:PackageOutputPath=./.artifacts -property:IncludeSymbols=true -p:SymbolPackageFormat=snupkg -target:pack -verbosity:m /bl C:\dev\GitHub\Handyman\src\Handyman.Azure.Functions\build/../src/Handyman.Azure.Functions.csproj
  Handyman.Azure.Functions -> C:\dev\GitHub\Handyman\src\Handyman.Azure.Functions\src\bin\release\netstandard2.0\publish\

C:\Users\jonas\.nuget\packages\microsoft.azure.webjobs.script.extensionsmetadatagenerator\1.1.2\build\Microsoft.Azure.WebJobs.Script.ExtensionsMetadataGenerator.targets(52,5): warning :     Could not evaluate 'Microsoft.CSharp.dll' for extension metadata. Exception message: Could not load file or assembly 'Microsoft.CSharp, Version=4.0.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. [C:\dev\GitHub\Handyman\src\Handyman.Azure.Functions\src\Handyman.Azure.Functions.csproj]

dotnet --info:

.NET Core SDK (reflecting any global.json):                                                                              Version:   2.2.401
 Commit:    729b316c13

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.18362
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\2.2.401\

Host (useful for support):
  Version: 2.2.6
  Commit:  7dac9b1b51
@brettsam
Copy link
Member

brettsam commented Aug 29, 2019

That warning isn't related. We try to look for extensions in every assembly in bin, and some platform assemblies can't be evaluated. We log a warning as an FYI, but it's not affecting this.

Functions projects themselves aren't packable: https://github.com/Azure/azure-functions-vs-build-sdk/blob/master/src/Microsoft.NET.Sdk.Functions.MSBuild/Targets/Microsoft.NET.Sdk.Functions.targets#L21.

That's why you're not getting anything. I see that in the binlog here too (looks like there's a warning setting that's also false):

Task "IsPackableFalseWarningTask" skipped, due to false condition; ('$(IsPackable)' == 'false' AND '$(WarnOnPackingNonPackableProject)' == 'true') was evaluated as ('false' == 'false' AND 'false' == 'true').

Instead, you should break out the pieces that you want to be redistributable as nuget packages into their own class library projects and pack them. Then your Functions project can reference that project.

@brettsam
Copy link
Member

brettsam commented Sep 3, 2019

Going to close this as Function apps are not packable. Let us know if you have more questions. Thanks!

@brettsam brettsam closed this as completed Sep 3, 2019
@ghost ghost locked as resolved and limited conversation to collaborators Dec 31, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants