locked
MSBuild with Universal Projects

    Question

  • Hi everyone,

    I cannot build a universal project (a class library portable for universal apps) with MSBuild in powershell, even though the project builds fine in Visual Studio 2013. I see the following errors:

    Converter\CollectionSizeToBooleanConverter.cs(11,53): error CS0246: The type or namespace name 'IValueConverter' could not be f
    ound (are you missing a using directive or an assembly reference?)
    Converter\ColorToBrushConverter.cs(9,23): error CS0234: The type or namespace name 'Data' does not exist in the namespace 'Wind
    ows.UI.Xaml' (are you missing an assembly reference?)
    Converter\ColorToBrushConverter.cs(15,42): error CS0246: The type or namespace name 'IValueConverter' could not be found (are y
    ou missing a using directive or an assembly reference?)
    Converter\DateAbbreviationConverter.cs(6,15): error CS0234: The type or namespace name 'Globalization' does not exist in the na
    mespace 'Windows' (are you missing an assembly reference?)

    So it seems that the references cannot be resolved. What could be the matter?

    I call MSBuild like this:

    C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe "/target:Clean;Build" /p:Configuration=Release /p:Platform="Any CPU" /p:OutDir=bin /p:GenerateProjectSpecificOutputFolder=true /p:StyleCopTreatErrorsAsWarnings=false /maxcpucount "Enough.XamlConverter.sln"

    Note that I explicitly call the 32bit version of MSBuild, since otherwise there is a problem with generated DLLs.

    Thanks everyone,

      Robert


    • Edited by enough2012 Wednesday, April 09, 2014 11:48 AM
    Wednesday, April 09, 2014 11:46 AM

Answers

  • Hi Robert,

    I was able to build my universal app fine and it builds the ANY CPU version as well.

    This is the version of MSBuild I am using (and where I am running from when I open a VC 2013 developer command prompt):

    C:\Users\jsanders\Documents\Visual Studio 2013\Projects\ConnectToCoolData>"C:\Pr
    ogram Files (x86)\MSBuild\12.0\Bin\msbuild.exe" /version
    Microsoft (R) Build Engine version 12.0.30324.0
    [Microsoft .NET Framework, version 4.0.30319.34014]
    Copyright (C) Microsoft Corporation. All rights reserved.

    12.0.30324.0

    • Ensure you are running the developer command prompt from: C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools\Shortcuts
    • Ensure you are using the same version of MSBuild.
    • Type MSBuild in the directory of your sln and see if it builds.
    • Build a simple Universal app and make sure that builds
    • Look at your project differences.  And compare a 'naked' universal app solution to yours

    Jeff


    Jeff Sanders (MSFT)

    @jsandersrocks - Windows Store Developer Solutions @WSDevSol
    Getting Started With Windows Azure Mobile Services development? Click here
    Getting Started With Windows Phone or Store app development? Click here
    My Team Blog: Windows Store & Phone Developer Solutions
    My Blog: Http Client Protocol Issues (and other fun stuff I support)

    • Proposed as answer by Robert_Enough Tuesday, April 15, 2014 10:08 AM
    • Marked as answer by enough2012 Tuesday, April 15, 2014 10:09 AM
    Monday, April 14, 2014 7:50 PM
    Moderator

All replies

  • Hi Robert,

    You should be able to use Procmon to capture the necessary build command.  I will try that later today, or you can download processmonitor and try it yourself and post the results!


    Jeff Sanders (MSFT)

    @jsandersrocks - Windows Store Developer Solutions @WSDevSol
    Getting Started With Windows Azure Mobile Services development? Click here
    Getting Started With Windows Phone or Store app development? Click here
    My Team Blog: Windows Store & Phone Developer Solutions
    My Blog: Http Client Protocol Issues (and other fun stuff I support)

    Thursday, April 10, 2014 1:20 PM
    Moderator
  • Thanks for the help, Jeff. With processmonitor I was able to see that Visual Studio uses another MSBuild version, notably

    'C:\Program Files (x86)\MSBuild\12.0\Bin\MSBuild.exe';

    This version can handle the universal project just fine, but being a 64bit version it cannot build for AnyCpu for Windows Phone projects in the same solution. I guess I could build each project on its own, but that's rather inconvenient. Any idea for this scenario?

    Friday, April 11, 2014 5:00 PM
  • Double check the phone project, make sure it is not x86 (the default for Emulator based debugging).

    Jeff Sanders (MSFT)

    @jsandersrocks - Windows Store Developer Solutions @WSDevSol
    Getting Started With Windows Azure Mobile Services development? Click here
    Getting Started With Windows Phone or Store app development? Click here
    My Team Blog: Windows Store & Phone Developer Solutions
    My Blog: Http Client Protocol Issues (and other fun stuff I support)

    Friday, April 11, 2014 6:31 PM
    Moderator
  • Thanks again, Jeff! I have the following configuration:(sorry,  I can't post images and I haven't figured out how I could verify my account)

    All projects are set to AnyPhone in the release configuration, only the unit test project for WP is set to x86 (but that's not causing any problem).

    The exact error is this:

    3>C:\Program Files (x86)\MSBuild\Microsoft\WindowsPhone\v8.0\Microsoft.WindowsPhone.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:\Users\Robert\SkyDrive\Projects\Enough.XamlConverter\Enough.WP.XamlConverter\Enough.WP.XamlConverter.csproj]    
    3>Done Building Project "C:\Users\Robert\SkyDrive\Projects\Enough.XamlConverter\Enough.WP.XamlConverter\Enough.WP.XamlConverter.csproj" (Clean target(s)) -- FAILED.    
    1>Done Building Project "C:\Users\Robert\SkyDrive\Projects\Enough.XamlConverter\Enough.XamlConverter.sln" (Clean;Build target(s)) -- FAILED.
    Build FAILED.


    Thanks,

      Robert

    Saturday, April 12, 2014 11:26 AM
  • Hi Robert,

    I was able to build my universal app fine and it builds the ANY CPU version as well.

    This is the version of MSBuild I am using (and where I am running from when I open a VC 2013 developer command prompt):

    C:\Users\jsanders\Documents\Visual Studio 2013\Projects\ConnectToCoolData>"C:\Pr
    ogram Files (x86)\MSBuild\12.0\Bin\msbuild.exe" /version
    Microsoft (R) Build Engine version 12.0.30324.0
    [Microsoft .NET Framework, version 4.0.30319.34014]
    Copyright (C) Microsoft Corporation. All rights reserved.

    12.0.30324.0

    • Ensure you are running the developer command prompt from: C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools\Shortcuts
    • Ensure you are using the same version of MSBuild.
    • Type MSBuild in the directory of your sln and see if it builds.
    • Build a simple Universal app and make sure that builds
    • Look at your project differences.  And compare a 'naked' universal app solution to yours

    Jeff


    Jeff Sanders (MSFT)

    @jsandersrocks - Windows Store Developer Solutions @WSDevSol
    Getting Started With Windows Azure Mobile Services development? Click here
    Getting Started With Windows Phone or Store app development? Click here
    My Team Blog: Windows Store & Phone Developer Solutions
    My Blog: Http Client Protocol Issues (and other fun stuff I support)

    • Proposed as answer by Robert_Enough Tuesday, April 15, 2014 10:08 AM
    • Marked as answer by enough2012 Tuesday, April 15, 2014 10:09 AM
    Monday, April 14, 2014 7:50 PM
    Moderator
  • Hi Jeff and all,

    Thanks for the additional pointer - the VS development prompt's MSBuild builds all projects just fine, including the Windows Phone Silverlight project (outside of the universal project).

    Thanks!

       Robert

    Tuesday, April 15, 2014 10:08 AM