Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Azure Function : build issue
bigmat
#1 Posted : Thursday, July 4, 2019 12:37:36 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 7/4/2019(UTC)
Posts: 1
Location: France

Hello,

I'm testing for my company Ncrunch vs R# Continuous Testing before purshasing licence for every developers.
For now, Ncrunch is far better for me but it does not work with Azure Functions :(

It looks like Ncrunch is not looking the good path to find the dll, in my code exemple Ncrunch looks here :
C:\Users\Bigmat\AppData\Local\NCrunch\17028\9\MyFunction\bin\Debug\netcoreapp2.2\MyFunction.dll

but the real path is :
C:\Users\Bigmat\AppData\Local\NCrunch\17028\9\MyFunction\bin\Debug\netcoreapp2.2\bin\MyFunction.dll

Is it possible to force the path where to look ? or Add this path on your side to check on ?

If someone has any work around I'm very interested because Azure Function is used a lot in our company.

Regards,
Mathieu
Remco
#2 Posted : Friday, July 5, 2019 12:02:41 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 5,982

Thanks: 781 times
Was thanked: 1008 time(s) in 960 post(s)
Hi, thanks for sharing this issue.

Unfortunately, the Azure platform (and its function projects) is not supported by NCrunch. I'm afraid that I can't offer any workaround to this problem.

It looks like Azure function support is a requested feature at the moment.

It's entirely possible that someone in the community knows of a workaround for this problem and is able to provide advice, but from the product side, unfortunately I can't help here.
arkiaconsulting
#3 Posted : Saturday, November 30, 2019 4:41:52 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 11/30/2019(UTC)
Posts: 2
Location: France

Thanks: 1 times
Was thanked: 4 time(s) in 1 post(s)
I succeeded in having a Function App build within NCrunch by adding the following to the Function csproj:

<Target Name="NCrunchBuild" AfterTargets="_GenerateFunctionsPostBuild" Condition=" '$(Configuration)' == 'Debug' ">
<Exec Command="xcopy /y &quot;$(TargetDir)bin\$(TargetName).*&quot; &quot;$(TargetDir)&quot;" />
</Target>

and setting the configuration parameter "Copy reference assemblies to workspace" to true (for the Function App project only).

If I don't set this setting, NCrunch build is unable to resolve NuGet assemblies.

But this may decrease NCrunch performances...
4 users thanked arkiaconsulting for this useful post.
Remco on 11/30/2019(UTC), UppSol on 12/1/2019(UTC), apokas on 1/21/2020(UTC), Clement on 2/21/2020(UTC)
Clement
#4 Posted : Friday, February 21, 2020 8:17:09 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 2/21/2020(UTC)
Posts: 2
Location: France

Thanks: 1 times
Was thanked: 2 time(s) in 2 post(s)
arkiaconsulting;14172 wrote:
I succeeded in having a Function App build within NCrunch by adding the following to the Function csproj:

<Target Name="NCrunchBuild" AfterTargets="_GenerateFunctionsPostBuild" Condition=" '$(Configuration)' == 'Debug' ">
<Exec Command="xcopy /y &quot;$(TargetDir)bin\$(TargetName).*&quot; &quot;$(TargetDir)&quot;" />
</Target>

and setting the configuration parameter "Copy reference assemblies to workspace" to true (for the Function App project only).

If I don't set this setting, NCrunch build is unable to resolve NuGet assemblies.

But this may decrease NCrunch performances...


Thanks for the useful target.

If you remove the Debug condition when publishing with dotnet CLI, don't forget to add --no-build switch to avoid twice copy.

Here is mine, a shorter one for paths and triggered only for the ncrunch build :
Code:

  <Target Name="CopyAzureFunctionOutput" AfterTargets="_GenerateFunctionsPostBuild" Condition="'$(NCrunch)' == '1'">
    <Exec Command="xcopy /y &quot;$(OutDir)\bin&quot; &quot;$(OutDir)&quot;" />
  </Target>


If you have multiple azure functions projet, you can also add this target inside a Directory.Build.targets file to apply the target on all projects.
1 user thanked Clement for this useful post.
arkiaconsulting on 2/21/2020(UTC)
Clement
#6 Posted : Tuesday, March 10, 2020 2:41:31 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 2/21/2020(UTC)
Posts: 2
Location: France

Thanks: 1 times
Was thanked: 2 time(s) in 2 post(s)
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 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.
1 user thanked Clement for this useful post.
alastairs on 3/24/2020(UTC)
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

YAF | YAF © 2003-2011, Yet Another Forum.NET
This page was generated in 0.064 seconds.