Azure-functions-vs-build-sdk: Build of Azure Functions project using Microsoft.NET.Sdk.Functions 1.0.8 fails with error Could not load file or assembly 'System.ValueTuple, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies.

Created on 21 Feb 2018  路  27Comments  路  Source: Azure/azure-functions-vs-build-sdk

Steps to reproduce the issue:

  • Create an Azure Functions project in Visual Studio 2017 using the existing project template (based on Azure Functions 1.0.2) and use .NET Framework 4.6.2 or 4.7
  • Update the nuget package to Azure Functions SDK 1.0.8
  • Create a simple timer trigger function
  • Compile the solution

Unable to compile the solution - it will through the error below

Severity Code Description Project File Line Suppression State
Error System.IO.FileNotFoundException: Could not load file or assembly 'System.ValueTuple, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The system cannot find the file specified.
File name: 'System.ValueTuple, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'
at MakeFunctionJson.FunctionJsonConverter.TryGenerateFunctionJsons()
at MakeFunctionJson.FunctionJsonConverter.TryRun()

WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].

Error generating functions metadata
funcIssueTest C:\Users\jplq631.nuget\packages\microsoft.net.sdk.functions\1.0.8\build\netstandard1.0\Microsoft.NET.Sdk.Functions.Build.targets 39

Most helpful comment

This should be an issue about the nuget package Microsoft.NET.Sdk.Functions with version 1.0.8. My current workaound is deleted the netstandard1.0 folder in that package:

"C:\Users\name.nuget\packages\microsoft.net.sdk.functions\1.0.8\build\netstandard1.0

Check the same issue on Stackoverfolw:

All 27 comments

Temporarily put System.ValueTuple.dll
to C:\Users\user.nuget\packages\microsoft.net.sdk.functions\1.0.8\tools\net46,
the build is completed.

I do not know well,
Microsoft.NET.Sdk.Functions.Generator.exe
v1.0.7/v1.0.8 dependency changed?

/pack/Microsoft.NET.Sdk.Functions/Microsoft.NET.Sdk.Functions.csproj
missing System.ValueTuple.dll

This should be an issue about the nuget package Microsoft.NET.Sdk.Functions with version 1.0.8. My current workaound is deleted the netstandard1.0 folder in that package:

"C:\Users\name.nuget\packages\microsoft.net.sdk.functions\1.0.8\build\netstandard1.0

Check the same issue on Stackoverfolw:

@liushuanggang Deleting the netstandard1.0 folder worked perfectly. thank you!

@jordan112 @liushuanggang . You should not be deleting that folder. That folder contains the targets required to build an publish functions projects correctly. Deleting the folder could impact functionality. Can you try falling back to previous version (1.0.7 ) to see if it fixes the issue? If it does, can you please provide a sample repro project here?

@vijayrkn I tried changing the version back to 1.0.6 and 1.0.7, same end result.

The version that the generator brings down is 4.4.0 of System.ValueTuple
https://github.com/Azure/azure-functions-vs-build-sdk/blob/master/src/Microsoft.NET.Sdk.Functions.Generator/Microsoft.NET.Sdk.Functions.Generator.csproj#L18

@ahmelsayed / @fabiocav - This looks like an issue with version of package that users project references vs the version enforced by generator. What is the recommendation here? Binding re-directs?

@vijayrkn reading other issue threads, i thought binding redirects were not supported with .net core. I tried a variety of approaches there and none of them had any effect.

@jordan112 - Are you not targeting net46?

I tried net461, net462 and net47. no change to anything until i deleted that build file

Deleting those build files will stop the function.json generation. Those targets contains the logic to auto-generate function.jsons

Right...understood. So compiles but doesn't necessarily work when deployed

What packages other than Microsoft.NET.Sdk.Functions 1.0.8 do you need to include to repro this issue?

I have

  <ItemGroup>
    <PackageReference Include="Microsoft.NET.Sdk.Functions" Version="1.0.8" />
    <PackageReference Include="System.ValueTuple" Version="4.4.0" />
  </ItemGroup>

but I can't repro this

actually I also tried with the whole list from the SO question and I still can't repro

<PackageReference Include="AWSSDK.S3" Version="3.3.11.4" />
<PackageReference Include="CqrsLite" Version="0.18.1" />
<PackageReference Include="Microsoft.Azure.DocumentDB" Version="1.20.2" />
<PackageReference Include="Microsoft.Azure.Management.CosmosDB.Fluent" Version="1.6.0" />
<PackageReference Include="Microsoft.Azure.WebJobs" Version="2.1.0" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.DocumentDB" Version="1.1.0" />
<PackageReference Include="Microsoft.Azure.WebJobs.ServiceBus" Version="2.1.0" />
<PackageReference Include="Microsoft.CrmSdk.XrmTooling.CoreAssembly" Version="8.2.0.5" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="1.0.8" />
<PackageReference Include="Newtonsoft.Json" Version="9.0.1" />
<PackageReference Include="SimpleInjector" Version="4.0.12" />
<PackageReference Include="System.ValueTuple" Version="4.4.0" />

Yeah, a binding redirect on the tool should help with this.
@jorisp you can probably just test this by adding a config file, named Microsoft.NET.Sdk.Functions.Generator.exe.config, with the redirect in the tool folder under:
<userprofile>\.nuget\packages\microsoft.net.sdk.functions\1.0.8\tools\net46

@ahmelsayed, that's a good point, I couldn't repro this either.

@jorisp, curious, what framework versions do you have installed?

I had a similar issue but only on the build server. One way I was able to work around it was to throw a copy of the System.ValueTuple.dll (4.4.0) into .nuget\packages\microsoft.net.sdk.functions\1.0.8\tools\net46 folder. It looks as if the issue (for me at least) is the tool can't find System.ValueTuple but only when it runs on the build server. I checked my local machine's GAC and found that I have a version of System.ValueTuple (4.0.0) installed. On the build server, this assembly is not in the GAC by the looks of it.

One option would be to install a copy into the GAC on the build server but it did beg the question, what have I installed locally that is not installed on the build server. The only thing I could see I only had locally was 4.7 SDK and Targeting Packs.

It turns out that 4.7 SDK and Targeting Packs are not installed in the community edition of visual studio by default and I'm guessing the same is true for the VS Build Tools 2017. I don't remember explicitly installing these locally so I'm assuming the latest version of visual studio 2017 pro edition installs these by default but I might be wrong.

Installing the 4.7 SDK and Targeting Pack components (open Visual Studio Installer and see "Individual Components" tab) on the build server has put version 4.0.0 of System.ValueTuple into the GAC and the build server now runs the sdk functions tool correctly and my solution now builds ok.

@mrgrok the recommendation above should allow you to run without the need to GAC that assembly,

so is the issue not having .NET 4.7 installed? .NET 4.7.1 is a hard requirement for functions runtime.
However, I can remove the dependency on System.ValueTuple completely from this project. the less dependencies this build task has the better.

@brandonwatmsft Thanks for confirming.

fixed by #173
Thanks @vijayrkn and everyone else!

Awesome guys! Do you know when this fix will go out, assuming 1.0.9 maybe?

@ahmelsayed - is there a release date for the package - 1.0.9?

we're in the process of releasing a new v2 runtime and cli. once that's done, I'll release 1.0.9. So hopefully mid-week next week

Thanks, @vijayrkn !

@jordan112 , in the meantime, either the binding redirect approach or copying the DLL to that tool folder should get you going.

hoping 1.09 hits today

@liushuanggang deleting this folder solved my issue:

C:\Users\name.nuget\packages\microsoft.net.sdk.functions\1.0.19\build\netstandard1.0

Currently using Azure Functions V2 Preview (.NET Standard 2.0).

@liushuanggang deleting this folder solved my issue:

C:\Users\name.nuget\packages\microsoft.net.sdk.functions\1.0.19\build\netstandard1.0

Currently using Azure Functions V2 Preview (.NET Standard 2.0).

worked for me also

Was this page helpful?
0 / 5 - 0 ratings