Msbuild fails to package a Service Fabric project with a c++ dependency - visual-c++

I have a Service Fabric project with this structure:
MyServiceFabric.sfproj
MyService.cspro
MyCommonCppMixedDll.vcxproj
If I compile from VS and from the command line:
msbuild MyServiceFabric.sfproj /p:Configuration="Release" /p:Platform="x64"
everything compiles as expected. When I try to Publish the project from VS, it works, but from the command line it fails. This is the command line I'm using:
msbuild MyServiceFabric.sfproj /p:Configuration="Release" /p:Platform="x64" /t:Package
the errors I'm getting, are related to the c++ project, that it fails to compile the platform Win32. If I remove the platform win32 from the c++ project, I receive the error:
This project t doesn't contain the Configuration and Platform combination of Release|Win32.
Obviously I don't want to compile half of the project in x64 and the c++ project in win32. For some strange reasons msbuild doesn't forward the platform to the c++ project.
I've seen in Microsoft.Cpp.Default.pros line #88 that if the platform is not specified, it default fall in Win32.
Any Ideas ?

Related

MSBuild on Centos returns "The imported project "/Microsoft.Cpp.Default.props" was not found"

I'm trying to build a VS project in CentOS. I installed dotnet-sdk-2.2 via yum install dotnet-sdk-2.2.
When executing dotnet msbuild myproj.vcxproj I get:
Microsoft (R) Build Engine version 16.1.76+g14b0a930a7 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.
mtproj.vcxproj(19,3): error MSB4019: The imported project "/Microsoft.Cpp.Default.props"
was not found. Confirm that the path in the <Import> declaration is correct, and that the
file exists on disk.
Googling results with many solutions but for Windows. what can I do to resolve this over Linux/CentOS?
According to your error message it's a C++ project.
Please check this document,the dotnet CLI only supports .NET / .NET Core / .NET Standard projects.
C++ projects are part of the visual studio tooling (c++ workload). The dotnet CLI doesn't contain the visual c++ compiler or the necessary windows SDKs. So it's not supported to build C++ projects directly using dotnet msbuild in Windows, not to speak of CentOS.
To build C++ projects in linux, you can try g++ compiler, you can find many related info about how to use it online.
Also, maybe you can try using GCCBuild to build vcxproj files in Linux. It simple uses same structure of vcxproj but uses GCC to compile and build. Thanks to Roozbeh.

Unable to build for Debug|x64 using MSBuild and VC++ Express edition

I have machine with VC++ Express Edition installed. And also .Net frameworks 2-4. I want to use msbuild through command line to build a VC++ project.
Issue is the build runs fine for Configuration=Debug;Platform=Win32 but for Configuration=Debug;Platform=x64 it gives an error that:
"….vcproj" (Clean;Build target) (1) ->
(Clean target) ->
vcbuild.exe : error VCBLD0004: Project ….vcproj' does not contain a configuration called 'Debug|x64'.
However if I view .csproj file directly it does have that configuration. I feel the issue is the missing x64 build tools. But while installing VC++ Express Edition it doesn't give an option to include x64 build tools like you get during complete Visual Studio 2008 installation.
So how can I get around that given that, I can't install a complete VS like there is on development environment because of several restriction.

PhoneGap add wp8 platform requires MSBuild x86

When trying to add the wp8 platform to a project, using:
phonegap local build wp8
It fails. Requiring msbuild x86.
C:\Program Files (x86)\MSBuild\Microsoft\WindowsPhone\v8.0\Microsoft.WindowsPhon
e.v8.0.Overrides.targets(15,9): error : Building Windows Phone application using
MSBuild 64 bit is not supported. If you are using TFS build definitions, change
the MSBuild platform to x86. [C:\funiz\platforms\wp8\Funiz.csproj]
ERROR: MSBuild failed to create .xap when building cordova-wp8 for debugging.
This is a Windows 8.1 machine, with Visual Studio Ultimate 2013, Update 2 RC.
The PATH environment variable is set to:
C:\Users\Yoram Kornatzky\AppData\Roaming\npm;C:\Windows\Microsoft.NET\Framework64\v4.0.30319;C:\Windows\Microsoft.NET\Framework\v4.0.30319
I tried removing the Frame64 element from the PATH. But it still fails.
Any insight would be appreciated.
You haven't specified the build template you are using. But if you are using DefaultTemplate in your team build definition, change value of parameter "MSBuild Platform" from Auto to X86

Debug version of vc++ project compains of missing msvcr80d.dll

I have a native c++ program exe which builds successfully and runs successfully in the release version. However when i try to run debug exe, it throws an exception "This application has failed to start because MSVCP80D.dll was not found. RE-installing the application may fix the proble,
Try statically linking the runtime libraries if you need to run a debug build on a PC that does not have Visual Studio installed.
http://msdn.microsoft.com/en-us/library/abx4dbyh(v=VS.100).aspx
That is because you don't have the DEBUG version of the C/C++ runtime on that machine, only the RELEASE builds. Debug builds are meant only for development and debugging. You should not install/distribute them, only Release builds. And you should install the appropriate redistributable with the VC++ runtimes.

How to compile C++ Projects from Command Line

I have to compile a Visual C++ solution from command line. I can't do it with devenv.exe but can install .Net Framework SDK. Can I use the solution and project files to compile from the command line? If so how?
If the .net framework SDK comes with msbuild, then just invoke:
msbuild mysolution.sln
That will cause a msbuild project to be generated from the solution, and the msbuild project will in turn instigate a call-out to vcbuild. All solution level and project level dependencies will then be resolved and built in-order as needed.

Resources