0

I have an azure function project, version 3, using .net core 3.1. In the project, I have a visual c++ project that has a dll that is needed in my project. Per the vendor, I have added the visual c++ project within my project and the .vcxproj file is included in my project as a reference. So file structure is /my project/projects/MPWrap/.vcxproj. Here is how I reference the Visual C++ project from my net core .csproj file.

<ItemGroup>
  <ProjectReference Include="projects\MPWrap\MPWrap.vcxproj" />
</ItemGroup>

In this visual c++ project, there is a Release folder which has a couple files including the .dll file that is needed for my project. There are no source code files in this project.

In my solution configuration screen, I do not have the build checkbox checked for this MPWrap project. Here is my solution configuration enter image description here

I can deploy to Azure Function from my local machine using Visual Studio. Here are my profile settings for my web deploy using Visual Studio. enter image description here

When I try to deploy using Azure dev ops pipeline, the build fails. I have tried many iterations of the configuration. When I try to use a DotNetCoreCLI@2 task, I get an error that it cannot find elements that are in the .vcxproj file, spcifically D:\Microsoft.Cpp.Default.props. I think this is due to where the project is building and it cannot find these values because they are not there.

I have also tried MSBuild task and VSBuild task which both produce the same error. If I set the configuration to Release and Any CPU, the MPWrap namespace cannot be found.

If I set the configuration to Release|x86 or Release|x64`, the build tries to build the Visual c++ project and gives me an error that it cannot find a source code file. When I build locally, the source code files are not present.

I am not sure what else to try and the vendor does not have experience deploying this to azure functions. This is typically deployed to a windows server with the full filesystem.

Is there any way to have my build take the dll from the Visual C++ project without trying to build it?

2
  • You can try to add <SelfContained>true</SelfContained> to csproj. Commented Dec 1, 2020 at 10:02
  • @user12163310 thanks for the suggestion. I tried it but it did not work. Commented Dec 2, 2020 at 13:36

1 Answer 1

0

I have also tried MSBuild task and VSBuild task which both produce the same error. If I set the configuration to Release and Any CPU, the MPWrap namespace cannot be found.

If I set the configuration to Release|x86 or Release|x64`, the build tries to build the Visual c++ project and gives me an error that it cannot find a source code file. When I build locally, the source code files are not present.

Account to your description, are you modifying the Solution Configuration?

1.If so, you should make sure your .NET core project can find the referenced MPWrap.dll. You can enable the build checkbox for MPWrap project in solution configuration, and then use VSBuild task to build whole solution with Release+Any CPU. So that both projects can build successfully.

2.Or you should add the generated MyWrap.dll, MyWrap.h into Git Source Control, and then reference these assemblies in .NET core project via code like DllImport. Then when building your .NET core project with Release+Any CPU, your C++ project won't be built and your .NET core project can still reference the MPWrap.dll which is under git repo.

In addition, dotnet build for now doesn't support building C++ project, cause dotnet cli doesn't know where to find the necessary C++ xx.targets and xx.props. You can refer to this case for details.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.