I'm trying to add ARM platform support to an existing Visual C++ project. I want to ensure the project can build Windows Phone and Windows Store apps in addition to X86 and X64 programs.
Microsoft does not appear to provide official documentation on the subject matter (or I can't seem to find it). In the absence of official documentation, I'm following the discussion provided on Microsoft Blogs at A guide to .vcxproj and .props file structure. I think the blog is quite good, and I don't think it has any defects, errors or omissions.
lib.vcxproj is an MCVE and its shown below. When I build an X86 or X64 target using a Visual Studio C++ project file from a VS{2010|2012|2013} X86 or X64 Developer Command Prompt, then things work as expected:
c:\Users\Test>msbuild /t:Build /p:Configuration=Debug;Platform=x64 lib.vcxproj
Microsoft (R) Build Engine version 4.6.1055.0
[Microsoft .NET Framework, version 4.0.30319.42000]
Copyright (C) Microsoft Corporation. All rights reserved.
Build started 10/7/2016 3:03:15 PM.
Project "c:\Users\Test\lib.vcxproj" on node 1 (Build target(s)).
...
Done Building Project "c:\Users\Test\lib.vcxproj" (Build target(s)).
Build succeeded.
0 Warning(s)
0 Error(s)
When I uncomment the ARM specific gear:
<ProjectConfiguration Include="Debug|ARM">
<Configuration>Debug</Configuration>
<Platform>ARM</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|ARM">
<Configuration>Release</Configuration>
<Platform>ARM</Platform>
</ProjectConfiguration>
Then switch to a ARM Developer Command Prompt and attempt to build it, the result is a failure:
c:\Users\Test>msbuild /t:Build /p:Configuration=Debug;Platform=ARM lib.vcxproj
Microsoft (R) Build Engine version 4.6.1055.0
[Microsoft .NET Framework, version 4.0.30319.42000]
Copyright (C) Microsoft Corporation. All rights reserved.
Build started 10/7/2016 7:43:12 PM.
Project "c:\Users\Test\lib.vcxproj" on node 1 (Build target(s)).
c:\Users\Test\lib.vcxproj : error MSB4057: The target "Build" does not exist in
the project.
Done Building Project "c:\Users\Test\lib.vcxproj" (Build target(s)) -- FAILED.
Build FAILED.
"c:\Users\Test\lib.vcxproj" (Build target) (1) ->
c:\Users\Test\lib.vcxproj : error MSB4057: The target "Build" does not exist i
n the project.
0 Warning(s)
1 Error(s)
All the ARM tools are installed correctly. I regularly build the project from the command line with Nmake using an ARM Developer Command Prompt.
According to the feedback at Can MSBuild be used to build a C++ project under ARM?, MSBuild does support ARM.
According to Difference between 2003 and current MSBuild schemas, I should continue to use the 2003 version of the schema.
How do I add ARM Platform support to existing Visual C++, MSBuild-based Project?
If you receive the "Compiling desktop applications for the ARM platform is not supported" error message, then add the following:
<ClCompile>
<PreprocessorDefinitions>WINAPI_FAMILY=WINAPI_FAMILY_PHONE_APP;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
It can be added to the ItemDefinitionGroup for ARM, near the PrecomiledHeader option.
lib.cpp
// One symbol
static const int s_int = 1;
lib.vcxproj
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<!-- BEGIN Added for ARM -->
<!--
<ProjectConfiguration Include="Debug|ARM">
<Configuration>Debug</Configuration>
<Platform>ARM</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|ARM">
<Configuration>Release</Configuration>
<Platform>ARM</Platform>
</ProjectConfiguration>
-->
<!-- END Added for ARM -->
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{111111-1111-1111-1111-111111111111}</ProjectGuid>
<RootNamespace>test</RootNamespace>
<PlatformToolset>v100</PlatformToolset>
<ConfigurationType>StaticLibrary</ConfigurationType>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings" />
<ImportGroup Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<!-- X86 Configurations -->
<ItemDefinitionGroup Condition="'$(Platform)'=='Win32'" Label="X86 Configuration">
<ClCompile>
<PrecompiledHeader />
</ClCompile>
<Lib>
<TargetMachine>MachineX86</TargetMachine>
<ImageHasSafeExceptionHandlers>true</ImageHasSafeExceptionHandlers>
</Lib>
</ItemDefinitionGroup>
<!-- X64 Configurations -->
<ItemDefinitionGroup Condition="'$(Platform)'=='x64'" Label="X64 Configuration">
<ClCompile>
<PrecompiledHeader />
</ClCompile>
<Lib>
<TargetMachine>MachineX64</TargetMachine>
</Lib>
</ItemDefinitionGroup>
<!-- ARM Configurations -->
<ItemDefinitionGroup Condition="'$(Platform)'=='ARM'" Label="ARM Configuration">
<ClCompile>
<PrecompiledHeader />
</ClCompile>
<Lib>
<TargetMachine>MachineARM</TargetMachine>
</Lib>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="lib.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
</Project>
No, this is not a duplicate. See the comment that explains why.
Related
I am currently trying to decouple a project and I am getting the following error
The OutputPath property is not set for project 'MyProj.vcxpro j'.
Please check to make sure that you have specified a valid combination
of Configuration and Platform for this project. Configuration=''
Platform='x64'. You may be seeing this message because you a re
trying to build a project without a solution file, and have specified
a non-default Configuration or Platform that doesn't exist for this
project. [D:\Test\MyProj.vcxproj]
I added this to my project but it is not helping
<PropertyGroup Label="Globals">
<Platform Condition="'$(Platform)' == ''">x64</Platform>
<TargetName>MyProj</TargetName>
<ResolveExportedSymbols>true</ResolveExportedSymbols>
<ProjectGuid>{xxxxx-xxxx-xxxx-xxx}</ProjectGuid>
<UsePrecompiledHeader>true</UsePrecompiledHeader>
<OutputPath>D:\MyOutput\out\</OutputPath>
</PropertyGroup>
Any suggestions ?
Please use this:
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform Condition="'$(Platform)' == ''">x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<TargetName>MyProj</TargetName>
<ResolveExportedSymbols>true</ResolveExportedSymbols>
<ProjectGuid>{xxxxx-xxxx-xxxx-xxx}</ProjectGuid>
<OutputPath>D:\MyOutput\out\</OutputPath>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
.....
</ClCompile>
</ItemDefinitionGroup>
.....
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
</Project>
Then, delete any output folder like Debug and then rebuild again.
Only For educational purposes.
Basically I am trying to compile Juicy Potato exploit. I found a visual studio project from github and Now I am trying to compile it using mono xbuild, Although it compiles without any errors but I can't find the binary or .exe files.
see below:
>>>> xbuild tool is deprecated and will be removed in future updates, use msbuild instead <<<<
XBuild Engine Version 14.0
Mono, Version 5.18.0.240
Copyright (C) 2005-2013 Various Mono authors
Build started 2019-10-10 3:30:02 PM.
__________________________________________________
/home/HTB/Json/10.10.10.158/nmap/juicy_potato/juicy-potato/JuicyPotato/JuicyPotato.sln: warning : Ignoring vcproj 'JuicyPotato'.
/home/HTB/Json/10.10.10.158/nmap/juicy_potato/juicy-potato/JuicyPotato/JuicyPotato.sln: warning : Failed to find project 4164003e-ba47-4a95-8586-d5aac399c050
/home/HTB/Json/10.10.10.158/nmap/juicy_potato/juicy-potato/JuicyPotato/JuicyPotato.sln: warning : Don't know how to handle GlobalSection ExtensibilityGlobals, Ignoring.
Project "/home/HTB/Json/10.10.10.158/nmap/juicy_potato/juicy-potato/JuicyPotato/JuicyPotato.sln" (default target(s)):
Target ValidateSolutionConfiguration:
Building solution configuration "Debug|x64".
Done building project "/home/HTB/Json/10.10.10.158/nmap/juicy_potato/juicy- potato/JuicyPotato/JuicyPotato.sln".
Build succeeded.
Warnings:
/home/HTB/Json/10.10.10.158/nmap/juicy_potato/juicy-potato/JuicyPotato/JuicyPotato.sln: warning : Ignoring vcproj 'JuicyPotato'.
/home/HTB/Json/10.10.10.158/nmap/juicy_potato/juicy-potato/JuicyPotato/JuicyPotato.sln: warning : Failed to find project 4164003e-ba47-4a95-8586-d5aac399c050
/home/HTB/Json/10.10.10.158/nmap/juicy_potato/juicy-potato/JuicyPotato/JuicyPotato.sln: warning : Don't know how to handle GlobalSection ExtensibilityGlobals, Ignoring.
3 Warning(s)
0 Error(s)
Time Elapsed 00:00:00.1375220
root#kali:/home/HTB/Json/10.10.10.158/nmap/juicy_potato/juicy-potato/JuicyPotato# ls
JuicyPotato JuicyPotato.sdf JuicyPotato.sln
root#kali:/home/HTB/Json/10.10.10.158/nmap/juicy_potato/juicy-potato/JuicyPotato# uname -a
Linux kali 4.19.0-kali3-amd64 #1 SMP Debian 4.19.20-1kali1 (2019-02-14) x86_64 GNU/Linux
my .vcxproj
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{4164003E-BA47-4A95-8586-D5AAC399C050}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>JuicyPotato</RootNamespace>
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
<ProjectName>JuicyPotato</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>```
Bottom:
```<PreprocessorDefinitions>NDEBUG;_WINDOWS;_USRDLL;MSFROTTENPOTATO_EXPORTS;_CRT_SECURE_NO_WARNINGS;% (PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>secur32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<BuildLog>
<Path>$(SolutionDir)$(Configuration)\$(Platform)\$(MSBuildProjectName).log</Path>
</BuildLog>
</ItemDefinitionGroup>
<ItemGroup>
<Text Include="ReadMe.txt" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="BlockingQueue.h" />
<ClInclude Include="IStorageTrigger.h" />
<ClInclude Include="LocalNegotiator.h" />
<ClInclude Include="MSFRottenPotato.h" />
<ClInclude Include="stdafx.h" />
<ClInclude Include="targetver.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="dllmain.cpp">
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</CompileAsManaged>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
</PrecompiledHeader>
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</CompileAsManaged>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
</PrecompiledHeader>
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</CompileAsManaged>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
</PrecompiledHeader>
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</CompileAsManaged>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
</PrecompiledHeader>
</ClCompile>
<ClCompile Include="IStorageTrigger.cpp" />
<ClCompile Include="LocalNegotiator.cpp" />
<ClCompile Include="JuicyPotato.cpp" />
<ClCompile Include="stdafx.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
</ClCompile>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>```
Architecture:
Linux kali 4.19.0-kali3-amd64 #1 SMP Debian 4.19.20-1kali1 (2019-02-14) x86_64 GNU/Linux
I'm trying to build my cordova application on Windows 10 but it fails because of the selected path i guess. I have Visual Studio 2017 installed and want to select the msbuild path at: C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin but the process always uses C:\Program Files (x86)\MSBuild\14.0\Bin for building the application.
I am not sure what the problem exactly is if the path is the problem or are there any problems with versions. The application wasn't developed by me so I'm not really familiar with where and why my problem is caused.
I have already tried to change my Windows path variable but it does not affect the build process. Also I switched from Visual Studio 2019 to 2017 because cordova build is not supported anymore.
My CordovaApp.Windows10.jsproj file:
<?xml version='1.0' encoding='utf-8'?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<OutputPath>build\windows\$(Configuration)\$(Platform)\win10\</OutputPath>
<IntermediateOutputPath>build\windows\bld\</IntermediateOutputPath>
<AppxPackageSigningEnabled>true</AppxPackageSigningEnabled>
</PropertyGroup>
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|AnyCPU">
<Configuration>Debug</Configuration>
<Platform>AnyCPU</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|ARM">
<Configuration>Debug</Configuration>
<Platform>ARM</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x86">
<Configuration>Debug</Configuration>
<Platform>x86</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|AnyCPU">
<Configuration>Release</Configuration>
<Platform>AnyCPU</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|ARM">
<Configuration>Release</Configuration>
<Platform>ARM</Platform>
<UseDotNetNativeToolchain>true</UseDotNetNativeToolchain>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
<UseDotNetNativeToolchain>true</UseDotNetNativeToolchain>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x86">
<Configuration>Release</Configuration>
<Platform>x86</Platform>
<UseDotNetNativeToolchain>true</UseDotNetNativeToolchain>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>f9b0ae20-c21c-42b9-9c4e-d8k328b4509e</ProjectGuid>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)' == 'Release'">
<UseDotNetNativeToolchain>true</UseDotNetNativeToolchain>
<EnableDotNetNativeCompatibleProfile>true</EnableDotNetNativeCompatibleProfile>
<Optimize>true</Optimize>
</PropertyGroup>
<PropertyGroup Condition="'$(CordovaBundlePlatforms)' != ''" Label="CordovaBuildParameters">
<AppxBundle>Always</AppxBundle>
<AppxBundlePlatforms>$(CordovaBundlePlatforms)</AppxBundlePlatforms>
</PropertyGroup>
<Import Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" />
<PropertyGroup Condition="'$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' < '14.0'">
<VisualStudioVersion>14.0</VisualStudioVersion>
</PropertyGroup>
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\$(WMSJSProjectDirectory)\Microsoft.VisualStudio.$(WMSJSProject).Default.props" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\$(WMSJSProjectDirectory)\Microsoft.VisualStudio.$(WMSJSProject).props" />
<PropertyGroup>
<TargetPlatformIdentifier>UAP</TargetPlatformIdentifier>
<TargetPlatformVersion>10.0.17763.0</TargetPlatformVersion>
<TargetPlatformMinVersion>10.0.16299.0</TargetPlatformMinVersion>
<MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion>
<UapDefaultAssetScale>100</UapDefaultAssetScale>
</PropertyGroup>
<PropertyGroup Condition="'$(VisualStudioVersion)' < '14.0'">
<TargetPlatformVersion>10.0</TargetPlatformVersion>
<TargetPlatformMinVersion>10.0</TargetPlatformMinVersion>
</PropertyGroup>
<ItemGroup>
<AppxManifest Include="package.windows10.appxmanifest">
<SubType>Designer</SubType>
</AppxManifest>
</ItemGroup>
<Import Label="Shared" Project="CordovaApp.projitems" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\$(WMSJSProjectDirectory)\Microsoft.VisualStudio.$(WMSJSProject).targets" />
<Target AfterTargets="ResolveAssemblyReferences" BeforeTargets="AfterResolveReferences" Condition="'$(Platform)' == 'AnyCPU'" Name="DetectMangedWinMDWithAnyCpu">
<Error Condition="'%(_ResolveAssemblyReferenceResolvedFiles.WinMDFile)' == 'true' AND '%(_ResolveAssemblyReferenceResolvedFiles.WinMDFileType)' == 'Managed'" Text="The following component requires .NET Native compilation which is not available when targeting 'Windows10' and 'AnyCPU'. Consider changing the targeted processor architecture to one of the following: 'x86, x64, ARM' (if you are using command line this could be done by adding '--archs' parameter, for example: 'cordova build windows --archs=x64'). %(_ResolveAssemblyReferenceResolvedFiles.Identity)" />
</Target>
<PropertyGroup>
<PreBuildEvent>node "$(ProjectDir)\\cordova\\prebuild-10.js"</PreBuildEvent>
<DisableFastUpToDateCheck>true</DisableFastUpToDateCheck>
</PropertyGroup>
</Project>
This is my console output:
Building project: C:\Users\Thomas\Desktop\output-win\platforms\windows\CordovaApp.Windows10.jsproj
Configuration : debug
Platform : x86
Buildflags : /p:CordovaBundlePlatforms=x86
MSBuildTools : C:\Program Files (x86)\MSBuild\14.0\bin
buildProject spawn: C:\Program Files (x86)\MSBuild\14.0\bin\msbuild [ 'C:\\Users\\Thomas\\Desktop\\output-win\\platforms\\windows\\CordovaApp.Windows10.jsproj',
'/clp:NoSummary;NoItemAndPropertyList;Verbosity=minimal',
'/nologo',
'/p:Configuration=debug',
'/p:Platform=x86',
'/p:CordovaBundlePlatforms=x86' ] { stdio: 'inherit' }
C:\Users\Thomas\Desktop\output-win\platforms\windows\CordovaApp.Windows10.jsproj(61,5): error MSB4019: The imported project "C:\Program Files (x86)\MSBuild\Mi
crosoft\VisualStudio\v14.0\Microsoft.VisualStudio..Default.props" was not found. Make sure that the path in the <Import> declaration is correct.
and the file exists on the disk.
No valid MSBuild was detected for the selected target: Error: C:\Program Files (x86)\MSBuild\14.0\bin\msbuild.exe: Command failed with exit code 1
I solved it own my own.
With the >cordova prepare command, which generates the windows platform including .sln file for Visual Studio and .jsproj files I changed my directory to \app\platforms\windows where the CordovaApp.Windows10.jsproj is located. After executing >MSBuild CordovaApp.Windows10.jsproj i got an other error message that was much clearer and after fixing i got my finished build.
I'm trying to compact a XML project file. The project compiles a single source file but its over 11 KB in size because of a penchant for duplicating the same settings multiple times. I'm trying to move per-source-file settings and hoisting them up into Configuration PropertyGroup with different condition statements or expressions (what does XML call them?).
If I am parsing A guide to .vcxproj and .props file structure from MSDN Blogs correctly, we can place the settings iin the property group:
<PropertyGroup Label=“Configuration“ />
<!– This property sheet (directly or via imports) defines the
default values for many tool-specific properties such as the
compiler’s Optimization, WarningLevel properties, Midl tool’s
TypeLibraryName property, etc...
However, when I check my modifications by closing VS and then re-opening it with the modified project file, none of the settings are picked up. Visual Studio appears to be using its own settings.
I have a few questions:
Is there a Visual Studio setting to tell it to stop sraying every setting into every source file? There's no reason to duplicate a setting 175x4 times for each source file crossed into each configuration.
Does Visual Studio have a compaction utility so I don't have to do this by hand? Its very tedious work.
Why is Visual Studio not picking up the settings? How do I fix it?
Here's a screen capture of a property page which includes Preprocessor Macros. The modified XML has the following, which is not reflected in Visual Studio. I've tried with and without the ClCompile.
<!-- Debug Configurations -->
<PropertyGroup Condition="'$(Configuration)'=='Release'" Label="Release Configuration">
<ClCompile>
<PreprocessorDefinitions>CRYPTOPP_DLL_ONLY;%(PreprocessorDefinitions)</PreprocessorDefinitions>
...
</ClCompile>
</PropertyGroup>
Here's the compacted project file. The original can be found here. The project compiles 1 source file, and its over 11KB in size un-compacted.
My mods start at <!-- All Configurations -->, and ends at <!-- Back to Visual Studio boilerplate -->. I have not finished hoisting all the settings, but the ones that have been done, like Preprocessor Macros and Runtime Library, are not reflected under Visual Studio.
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{1974a53a-9863-41c9-886d-b2b8c2fc3c8b}</ProjectGuid>
<RootNamespace>dlltest</RootNamespace>
<PlatformToolset>v100</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<!-- All Configurations -->
<PropertyGroup Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseOfMfc>false</UseOfMfc>
<CharacterSet>MultiByte</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
<OutDir>$(Platform)\DLL_Output\$(Configuration)\</OutDir>
<IntDir>$(Platform)\$(ProjectName)\$(Configuration)\</IntDir>
<ClCompile>
<WarningLevel>Level4</WarningLevel>
<CallingConvention>StdCall</CallingConvention>
<SuppressStartupBanner>true</SuppressStartupBanner>
</ClCompile>
</PropertyGroup>
<!-- Debug Configurations -->
<PropertyGroup Condition="'$(Configuration)'=='Debug'" Label="Debug Configuration">
<ClCompile>
<PreprocessorDefinitions>CRYPTOPP_DLL_ONLY;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<Optimization>Disabled</Optimization>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<IntrinsicFunctions>true</IntrinsicFunctions>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
</ClCompile>
</PropertyGroup>
<!-- Release Configurations -->
<PropertyGroup Condition="'$(Configuration)'=='Release'" Label="Release Configuration">
<ClCompile>
<PreprocessorDefinitions>NDEBUG;CRYPTOPP_DLL_ONLY;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<OmitFramePointers>true</OmitFramePointers>
<IntrinsicFunctions>true</IntrinsicFunctions>
<FunctionLevelLinking>true</FunctionLevelLinking>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
</ClCompile>
</PropertyGroup>
<!-- X86 Configurations -->
<PropertyGroup Condition="'$(Platform)'=='Win32'" Label="X86 Configuration">
<ClCompile>
<EnableEnhancedInstructionSet>StreamingSIMDExtensions2</EnableEnhancedInstructionSet>
</ClCompile>
</PropertyGroup>
<!-- X64 Configurations -->
<PropertyGroup Condition="'$(Platform)'=='x64'" Label="X64 Configuration">
<ClCompile>
<!-- <EnableEnhancedInstructionSet>StreamingSIMDExtensions2</EnableEnhancedInstructionSet> -->
<EnableEnhancedInstructionSet>StreamingSIMDExtensions</EnableEnhancedInstructionSet>
</ClCompile>
</PropertyGroup>
<!-- Back to Visual Studio boilerplate -->
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<StringPooling>true</StringPooling>
<PrecompiledHeader />
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>%(PreprocessorDefinitions)</PreprocessorDefinitions>
<Culture>0x0409</Culture>
</ResourceCompile>
<Link>
<AdditionalDependencies>cryptopp.lib;Ws2_32.lib</AdditionalDependencies>
<AdditionalLibraryDirectories>$(Platform)\DLL_Output\$(Configuration)</AdditionalLibraryDirectories>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<StringPooling>true</StringPooling>
<PrecompiledHeader />
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>%(PreprocessorDefinitions)</PreprocessorDefinitions>
<Culture>0x0409</Culture>
</ResourceCompile>
<Link>
<AdditionalDependencies>cryptopp.lib;Ws2_32.lib</AdditionalDependencies>
<AdditionalLibraryDirectories>$(Platform)\DLL_Output\$(Configuration)</AdditionalLibraryDirectories>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<TargetMachine>MachineX64</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader />
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>%(PreprocessorDefinitions)</PreprocessorDefinitions>
<Culture>0x0409</Culture>
</ResourceCompile>
<Link>
<AdditionalDependencies>cryptopp.lib;Ws2_32.lib</AdditionalDependencies>
<AdditionalLibraryDirectories>$(Platform)\DLL_Output\$(Configuration)</AdditionalLibraryDirectories>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader />
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>%(PreprocessorDefinitions)</PreprocessorDefinitions>
<Culture>0x0409</Culture>
</ResourceCompile>
<Link>
<AdditionalDependencies>cryptopp.lib;Ws2_32.lib</AdditionalDependencies>
<AdditionalLibraryDirectories>$(Platform)\DLL_Output\$(Configuration)</AdditionalLibraryDirectories>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<TargetMachine>MachineX64</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="dlltest.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
Your settings are overwritten because you put them too early in the file. Do as VS does, and put them after the <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />.
update my mistake; on second sight, your settings don't have any effect whatsoever since you are defining them as properties. Do as VS does, and define them in an ItemDefinitionGroup instead of a PropertyGroup (again, in the correct location as per msbuild evaluation rules)
As for the compacting: store your settings in seperate property sheets and import those. If organized wisely this will allow you to never have to edit the project file settings itself anymore (and hence the VS populated ItemDefinitionGroups will be empty), but you'll just add/remove property sheets as needed and the project file is just a container for source/header files and property sheets. If you do the importing in the VS gui (called 'Property Manager') they will automatically end up in the correct location mentioned before, and the order will also be ok. They can also be edited in VS via the same options dialog as for the project.
Note you can create whole hierarchies of property sheets importing others, which is useful to avoid repetition. E.g. instead of manually adding Ws2_32.lib to each config/platform combo you just import a property sheet which does just that. Especially handy for libraries which have different names depending on platform/configuration etc. And suppose you have created some standard property sheets seperate for compiler/linker/... you can add them to a 'master' one. Sample:
I want to to create a VC++ project with C#. I see this MSDN article about creating C# and VB console application projects. But how to do with VC++ project?
ADD 1
I had exactly the same issue as below thread. And its solution is to manipulate the raw XML, which is miserable... Is there some kind of API that I can work with?
How can an Empty Visual C++ project be created programmatically?
ADD 2
And besides creating a .vcxproj fie. I want to programmatically create a solution .sln file. Because my codebase are separated into many projects.
OK. I solved this problem by manipulating the *.sln and *.vcxproj files directly.
Details:
For *.vcxproj file, I created the following template:
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
__SM_C_FILES__
</ItemGroup>
<ItemGroup>
__SM_H_FILES__
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>__SM_PROJECT_GUID__</ProjectGuid>
<RootNamespace>__SM_PROJECT_ROOTNS__</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup />
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>__SM_ADDITIONAL_INCLUDE_DIRS_DEBUG__</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>__SM_ADDITIONAL_INCLUDE_DIRS_RELEASE__</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
The __SM_C_FILES__ contains sub-template like this:
<ClCompile Include="__SM_C_FILE__" />
The __SM_H_FILES__ contains sub-template like this:
<ClInclude Include="__SM_H_FILE__" />
For *.sln file, I created a template as below:
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.40629.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "__SM_PROJ_NAME__", "__SM_PROJ_FILE_PATH__", "__SM_PROJ_GUID__"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{__SM_PROJ_GUID__}.Debug|Win32.ActiveCfg = Debug|Win32
{__SM_PROJ_GUID__}.Debug|Win32.Build.0 = Debug|Win32
{__SM_PROJ_GUID__}.Release|Win32.ActiveCfg = Release|Win32
{__SM_PROJ_GUID__}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
Note the __SM_*__parts, I replace them with the project-specific content using the plain string replacement, which is pretty straight-forward.
And in the *.sln file, if you have multiple projects, you may need to generated multiple parts of the Project sections.
The {8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942} is a well-known GUID that represents the VC++ project type. A comprehensive list can be found here.
Thus, I avoided manipulating the XML.
Unlike this similar thread, I didn't create the *.vcxproj.filters file. Though it looks a bit ugly, but I can live with that for now.