I have a class library assembly that I have created in Visual Studio 2012. I am wondering what parameters I should use to make sure the class library works under ARM, x86, and x64 for WinRT. I currently have the project properties defined as AnyCPU.
Is all I need to do is define the NETFX_CORE constant? Is there somewhere I specify for WinRT or the CPU?
C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe MyClassLibrary.csproj
/t:Rebuild /p:Configuration=DEBUG /p:DefineConstants="NETFX_CORE"
It is the same for WinRT, as for a desktop applications -- parameter is /p:Platform=<name>. E.g.:
msbuild MyClassLibrary.csproj /p:Configuration=Debug /p:Platform=ARM
Related
I've set up a build process in Visual Studio Team Services for a UWP solution using an agent on my box. My solution contains a mix of C++ and managed projects (2 projects are C++, other are C#). My problem is that x86 build fails, while for x64 and ARM platforms the build completes successfully.
From what I'm seeing from the build log, it is incorrectly treating Win32 platform as x64, and putting the resulting *.lib file into bin\Release\x64 folder instead of bin\Release\Win32, where the next project is supposed to pick it up from:
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\x86_amd64\Lib.exe /OUT:"C:\Agent\_work\1\s\MyProj\MyProject1\bin\Release\x64\MyProject1.lib" /NOLOGO /LTCG C:\Agent\_work\1\s\MyProj\MyProject1\obj\Release\x64\test.obj
Any suggestions on how to fix that are greatly appreciated.
The issue was happening because I didn't have multi-configuration set up. To be able to build the solution for multiple platforms/configruations, this is a mandatory setting. When I got that set, the build started to succeed.
I'm using Visual studio 2013 and I'm want to compile my project for linux (with MONO).
Is this possible to use VS2013 (with or without mono plugin) to compile my project to MONO file?
Yes, you'll be fine to use VS to build a .NET project that can run against Mono.
You'll be fine with the stock csc compiler and MSBuild (as both csc and the Mono compiler generate CIL all the same) just make sure that your project references Mono's assemblies rather than .NET's where there are breaking differences (e.g. System.Windows.Forms, etc). If you're doing ASP.NET or Console applications you should be fine without doing anything special.
As long as you use the versions of the DLLs that come from nuget instead of the references that are added by default by Visual Studio you should be fine, provided you recompile everything with xbuild.
At the moment there are some minor differences in the CIL that is outputted by msbuild and what the mono VM can run.
Just run xbuild in the root directory of your solution or project. It will detect the .sln/.proj file and build everything.
I'm using Visual Studio 2010 to build a c# project that has both x86 and x64 targets. When I build using the IDE, I get the correct result of x64 and x86 targets.
When I use msbuild on the command line, I get everything built in x86, even though i specify x64 on the command line.
I didn't have this problem until I upgraded from .Net 4.0 to .Net 4.5.
With .Net 4.0 I was able to get my x64 targets even if I specified x86 on the command line.
I did a build in the .Net 4.0 environment and then another build in the .Net 4.5 environment and piped the output into log files. I noticed some differences in the log files but I think this is what is causing my issue:
In .Net 4.0 I see this line in the log file:
/reference:C:\Windows\Microsoft.Net\assembly\GAC_MSIL\Microsoft.CSharp\v4.0_4.0.0.0__b03f5f7f11d50a3a\Microsoft.CSharp.dll
In .Net 4.5 I see this line in the log file:
/r:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.0\Microsoft.CSharp.dll"
Any ideas? It seams .Net 4.5 is using an x86 specific path.
This could happen if your solution's x64 configuration is configured to build project as AnyCPU. A new configuration option in .Net 4.5, Prefer 32 bit, makes executables with Prefer32bit flag to start up as 32-bit processes on 64 bit machine. Since Prefer32bit flag is default in MSBuild targets, you will see the behavior you describe, i.e. upgrading from .Net 4.0 to .Net 4.5 will have your AnyCPU project to switch from 64 bit to 32 bit.
To make project (not solution) built for x64, specify it on command line:
msbuild project.csproj /p:Platform=x64
Notice, the command line is for .csproj, not for .sln.
Alternatively, verify you solution configuration in Configuration Manger and make sure it gets built as x64.
I have a solution that is being referenced by a MSBuild project. In the solution, I am referencing several projects that are targeting .NET 4.0. How can I tell MSBuild to ignore the project's configuration and just target .NET 3.5?
A command similar to the following should work
msbuild YourSolution.sln /tv:3.5 /p:TargetFrameworkVersion=v3.5
or
msbuild YourSolution.sln /p:TargetFrameworkVersion=v3.5
/tv (or /toolsversion) Indicates which version of the MSBuild tools you want to use, and the property TargetFrameworkVersion indicates the target framework. In your case just specifying that property should be fine, but if you want to use the 3.5 MSBuild toolset you can sepcify it with /tv as I did in the first command.
It seems to be added automagically in every project I create and I compile for x64 but it doesn't even appear in the project's Configuration Properties/(C/C++)/Preprocessor when selecting the x64 configuration.
_WIN64 is automatically defined by Visual Studio. See the list of Predefined Macros.