locked
Project compatible with VS Express for Windows 8 and VS Express for Windows Phone

    Question

  • I want to build an app for both windows 8 (store app) and windows phone 8. I want a class library (in C#) which contains common classes. Since I use the epxress editions, I can't build a portable class library. So, what options do I have? I don't want two projects and repeatetly having to copy code. I don't want to use the file link technique either, because I imagine this would be almost as tedious as copying the code for a larger amount of files and I don't want to keep all my code in one file.

    I don't mind compiling the project twice, once for WinRT and once for the Windows Phone Runtime, but I don't want to maintain two projects. So I need a project template, which I can open and build from both VS Express for Windows 8 and VS Express for Windows Phone. Can anyone help me with that?

    Here's what I already did. I experimented with the project file and I can now open it from both vs express versions, but it fails to build.

    <?xml version="1.0" encoding="utf-8"?>
    <Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
      <PropertyGroup Condition=" '$(Platform)' == 'WinRT' ">
        <Platform>WinRT</Platform>
        <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
        <ProductVersion>8.0.30703</ProductVersion>
        <SchemaVersion>2.0</SchemaVersion>
        <ProjectGuid>{9485F7A2-7263-44F5-8294-38C7319B98CF}</ProjectGuid>
        <OutputType>Library</OutputType>
        <AppDesignerFolder>Properties</AppDesignerFolder>
        <RootNamespace>TestLib</RootNamespace>
        <AssemblyName>TestLib</AssemblyName>
        <DefaultLanguage>en-US</DefaultLanguage>
        <FileAlignment>512</FileAlignment>
      </PropertyGroup>
      <PropertyGroup Condition=" '$(Platform)' == 'WPRT' ">
        <Platform>WPRT</Platform>
        <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
        <ProductVersion>10.0.20506</ProductVersion>
        <SchemaVersion>2.0</SchemaVersion>
        <ProjectGuid>{9485F7A2-7263-44F5-8294-38C7319B98CF}</ProjectGuid>
        <ProjectTypeGuids>{C089C8C0-30E0-4E22-80C0-CE093F111A43};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
        <OutputType>Library</OutputType>
        <AppDesignerFolder>Properties</AppDesignerFolder>
        <RootNamespace>TestLib</RootNamespace>
        <AssemblyName>TestLib</AssemblyName>
        <TargetFrameworkIdentifier>WindowsPhone</TargetFrameworkIdentifier>
        <TargetFrameworkVersion>v8.0</TargetFrameworkVersion>
        <SilverlightVersion>$(TargetFrameworkVersion)</SilverlightVersion>
        <SilverlightApplication>false</SilverlightApplication>
        <ValidateXaml>true</ValidateXaml>
        <MinimumVisualStudioVersion>11.0</MinimumVisualStudioVersion>
        <ThrowErrorsInValidation>true</ThrowErrorsInValidation>
      </PropertyGroup>
      <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|WinRT' ">
        <DebugSymbols>true</DebugSymbols>
        <DebugType>full</DebugType>
        <Optimize>false</Optimize>
        <OutputPath>bin\Debug\</OutputPath>
        <DefineConstants>DEBUG;TRACE;NETFX_CORE</DefineConstants>
        <ErrorReport>prompt</ErrorReport>
        <WarningLevel>4</WarningLevel>
      </PropertyGroup>
      <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|WinRT' ">
        <DebugType>pdbonly</DebugType>
        <Optimize>true</Optimize>
        <OutputPath>bin\Release\</OutputPath>
        <DefineConstants>TRACE;NETFX_CORE</DefineConstants>
        <ErrorReport>prompt</ErrorReport>
        <WarningLevel>4</WarningLevel>
      </PropertyGroup>
      <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|WPRT' ">
        <DebugSymbols>true</DebugSymbols>
        <DebugType>full</DebugType>
        <Optimize>false</Optimize>
        <OutputPath>Bin\Debug</OutputPath>
        <DefineConstants>DEBUG;TRACE;SILVERLIGHT;WINDOWS_PHONE</DefineConstants>
        <NoStdLib>true</NoStdLib>
        <NoConfig>true</NoConfig>
        <ErrorReport>prompt</ErrorReport>
        <WarningLevel>4</WarningLevel>
      </PropertyGroup>
      <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|WPRT' ">
        <DebugType>pdbonly</DebugType>
        <Optimize>true</Optimize>
        <OutputPath>Bin\Release</OutputPath>
        <DefineConstants>TRACE;SILVERLIGHT;WINDOWS_PHONE</DefineConstants>
        <NoStdLib>true</NoStdLib>
        <NoConfig>true</NoConfig>
        <ErrorReport>prompt</ErrorReport>
        <WarningLevel>4</WarningLevel>
      </PropertyGroup>
      <ItemGroup>
        <!-- A reference to the entire .Net Framework and Windows SDK are automatically included -->
      </ItemGroup>
      <ItemGroup>
        <Compile Include="TestClass.cs" />
      </ItemGroup>
      <PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '11.0' ">
        <VisualStudioVersion>11.0</VisualStudioVersion>
      </PropertyGroup>
      <PropertyGroup>
        <RootNamespace>TestLib</RootNamespace>
      </PropertyGroup>
      <PropertyGroup>
        <OutputType>Library</OutputType>
      </PropertyGroup>
      <PropertyGroup>
        <StartupObject />
      </PropertyGroup>
      <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="'$(Platform)' == 'WinRT'  And Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
      <Import Project="$(MSBuildExtensionsPath)\Microsoft\WindowsXaml\v$(VisualStudioVersion)\Microsoft.Windows.UI.Xaml.CSharp.targets" Condition=" '$(Platform)' == 'WinRT' " />
      <Import Project="$(MSBuildExtensionsPath)\Microsoft\$(TargetFrameworkIdentifier)\$(TargetFrameworkVersion)\Microsoft.$(TargetFrameworkIdentifier).$(TargetFrameworkVersion).Overrides.targets" Condition=" '$(Platform)' == 'WPRT' " />
      <Import Project="$(MSBuildExtensionsPath)\Microsoft\$(TargetFrameworkIdentifier)\$(TargetFrameworkVersion)\Microsoft.$(TargetFrameworkIdentifier).CSharp.targets" Condition=" '$(Platform)' == 'WPRT' " />
      <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
           Other similar extension points exist, see Microsoft.Common.targets.
      <Target Name="BeforeBuild">
      </Target>
      <Target Name="AfterBuild">
      </Target>
      -->
    </Project>

    https://fraktalysator.codeplex.com/


    Monday, September 2, 2013 10:53 AM

Answers

All replies

  • You don't understand how to properly connect two project together.  Your class library should be a seperate project.  A seperate project is exactly the same as using any of the Net Libraries where you add a a Net library to your project by putting a 'using' in C# or 'import' in VBnet.  All you need to do is to Add Reference from the VS menu and choose the BROWSE option.  Then browse for the dll in the class Library project.  Then add to you project a 'using' or 'import' using the namespace of you class library.  The dependencies in the main project can be setup so any changes to the source in th eclass library will automaticaly have both projects to compile.

    When you use a Net Library like Regex the namespace is Regex and the library is Regex.dll.


    jdweng

    Monday, September 2, 2013 11:50 AM
  • I believe you misunderstood my question. I'm not asking how to use an existing library.

    Since WinRT and Windows Phone Runtime are not binary compatible, I can't reference a single dll (except if it was a portable class library, which I can't build due to Express Edition limitations). So I need two dll's, two versions of the same class library, compiled from the same code, but once for WinRT and once for windows phone. So what I need is a project file which I can open and compile from both "VS 2012 for Windows 8" and "VS 2012 for Windows Phone".


    https://fraktalysator.codeplex.com/

    Monday, September 2, 2013 4:02 PM
  • Hello,

    I have moved this thread to Tools for Windows Store apps forum for better response.

    Best regards,


    Amanda Zhu <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Tuesday, September 3, 2013 6:16 AM
  • The Express editions simply do not support projects like this. You need the Pro edition or higher to target multiple platforms with the same project/solution.

    See http://code.msdn.microsoft.com/wpapps/Visual-Studio-3D-Starter-455a15f1

    Tuesday, September 3, 2013 6:49 AM
  • Ok, thanks for the reply. But I don't really get, how your link is related to my question.

    Why this epxress limitation? I can get VS Professional for free through DreamSpark, but I would have rather sticked to the express version, and I guess a lot of other developers have the same problem..


    https://fraktalysator.codeplex.com/

    Tuesday, September 3, 2013 10:59 AM
  • The sample is an example of a 'both Windows Store and Windows phone' project. It explicitly requires Pro or later.
    Tuesday, September 3, 2013 6:44 PM