[Visual Studio] Referencing Functions Project (eg. Unit Testing) points to wrong path.
After update to Latest Stable Microsoft.NET.Sdk.Functions 1.0.0 build path of *.dll's changed from
\bin\Debug\net461 to \bin\Debug\net461\bin
Actually the folders are less messy (even though it looks very badly \bin\*\bin), BUT it breaks any other projects, that may be referencing Functions Project (like unit testing ones). They still look for dll in \net461 path.
This cause Visual Studio to throw error at building referencing project:
Error CS0006 : Metadata file '*\FunctionApp2\FunctionApp2\bin\Debug\net461\FunctionApp2.dll' could not be found
Not nicest fix is to reference not a project but *.dll file, and build Projects one by one.
Same problem here
Same problem here too - we also tried to find a work around over the weekend, but also came to the conclusion that referencing the dll was the only workaround option for now, which brings about it's own problems in build,
@vijayrkn Could you take a look? Another option is to go back to our previous system, where only the publish layout uses the extra 'bin' folder.
I don't know how TargetPath var is created in VS project, but if you only fix that one to point to correct dir with extra bin/+ filename.dll, it should fix all problems.
Other easy way is to use post build action to copy bin/Debug/net461/bin/* one level up. It duplicate output dlls but at least project can be referred again.
On 16 Aug 2017 12:01 am, "Donna Malayeri" [email protected] wrote:
@vijayrkn https://github.com/vijayrkn Could you take a look? Another option is to go back to our previous system, where only the publish layout uses the extra 'bin' folder.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Azure/Azure-Functions/issues/441#issuecomment-322602011, or mute the thread https://github.com/notifications/unsubscribe-auth/AGsQWh0rCK66LGux6guQwx-8JUT0KGhqks5sYhUrgaJpZM4O3gNc .
@rawlukMike - we do fix the TargetPath (https://github.com/Azure/azure-functions-vs-build-sdk/blob/5b29350d1bfaaefae6a287ea6019956001c35d2d/src/Microsoft.NET.Sdk.Functions/Targets/netstandard1.0/Microsoft.NET.Sdk.Functions.Build.targets#L138) to point to the correct location. Looks like this will not get called when functions project references a normal class lib. Let me check if I can apply the same target to non-function projects.
This is an issue only when the referenced class lib project is not on the same project system as functions project. Work-around: https://github.com/vijayrkn-test/FunctionsProjectWithClassLib - this is a sample functions project that references an xunit project & mstest project and this builds fine.
@vijayrkn I confirm that using new style of project works, but by default VS is creating different one.
Also when looking into macros section you can see that TargetPath is still broken (or at least not displayed there correctly), are you 100% sure the build targets are set correctly ?

Thanks for help !
Fixed this issue with this PR https://github.com/Azure/azure-functions-vs-build-sdk/pull/98.
Also added the following scenario coverage as part of building the functions sdk itself.
- Function app project with references to Classic class lib & Sdk style class lib
- Classic unit test project with reference to a sample Function app and running the tests from this project to make sure references from class lib project works.
- SDK style unit test projects (mstest and xunit) with reference to function app and running tests from these test projects to verify this works.
@vijayrkn I can see that you've bumped the version to 1.0.2. 1.0.1 looks to have gone public on nuget yesterday. Do you know when 1.0.2 will be on the public nuget?
@TheeJamesLee We've just released 1.0.2.
Fixed in 1.0.2: https://www.nuget.org/packages/Microsoft.NET.Sdk.Functions
I tried to enable static code analysis for an Azure Function project but its failing due to the additional bin folder in the output path. Static Code Analysis is looking for the assemblies one directory up since I believe its using TargetPath directory which isn't updated to include the additional bin folder. Do you know if there's a workaround for this?
I enabled Static Code Analysis by editing the project file like so:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net461</TargetFramework>
<RunCodeAnalysis>true</RunCodeAnalysis>
<CodeAnalysisRuleSet>ExtendedDesignGuidelineRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>