I was facing to a bigger problem than just copy some moved binaries with the azure functions targets :
Code:Mono.Cecil.AssemblyResolutionException: Failed to resolve assembly: 'Microsoft.Azure.WebJobs.Extensions.Http, Version=3.0.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
I have done a better version in order to skip directly the Microsoft.NET.Sdk.Functions targets; here is the details :
In the obj folder, a file <project>.nuget.g.targets contains the associated imported targets like that :
Code:<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
</PropertyGroup>
<ImportGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<Import Project="$(NuGetPackageRoot)netstandard.library\2.0.3\build\netstandard2.0\NETStandard.Library.targets" Condition="Exists('$(NuGetPackageRoot)netstandard.library\2.0.3\build\netstandard2.0\NETStandard.Library.targets')" />
<Import Project="$(NuGetPackageRoot)microsoft.extensions.configuration.usersecrets\3.1.2\build\netstandard2.0\Microsoft.Extensions.Configuration.UserSecrets.targets" Condition="Exists('$(NuGetPackageRoot)microsoft.extensions.configuration.usersecrets\3.1.2\build\netstandard2.0\Microsoft.Extensions.Configuration.UserSecrets.targets')" />
<Import Project="$(NuGetPackageRoot)microsoft.azure.webjobs.script.extensionsmetadatagenerator\1.1.5\build\Microsoft.Azure.WebJobs.Script.ExtensionsMetadataGenerator.targets" Condition="Exists('$(NuGetPackageRoot)microsoft.azure.webjobs.script.extensionsmetadatagenerator\1.1.5\build\Microsoft.Azure.WebJobs.Script.ExtensionsMetadataGenerator.targets')" />
<Import Project="$(NuGetPackageRoot)microsoft.net.sdk.functions\3.0.5\build\Microsoft.NET.Sdk.Functions.targets" Condition="Exists('$(NuGetPackageRoot)microsoft.net.sdk.functions\3.0.5\build\Microsoft.NET.Sdk.Functions.targets')" />
</ImportGroup>
</Project>
As you can see, to disable the targets loading, you can set the ExcludeRestorePackageImports property to true in your project referencing the azure function package like this:
Code:
<PropertyGroup Condition="'$(NCrunch)' == '1'">
<ExcludeRestorePackageImports>true</ExcludeRestorePackageImports>
</PropertyGroup>
That way, the targets is not triggered, the files are not moved into the bin folders and NCrunch works fine.