Xavier Peña
Xavier Peña

Reputation: 7919

How to build .xproj before .csproj

This is a follow-up from this question.

As I'm not able to directly reference my .xproj in my .csproj in Visual Studio, I am forced to directly reference the built net461 dll. So in this situation, I want my .csproj to pre-compile the .xproj before running the .csproj itself.

I've tried modifying the .csproj manually and adding:

<ItemGroup>
   <ProjectReference Include="..\SomeFolder\SomeProject.xproj">
      <Project>{1A94B405-2D01-4A09-90D5-A5B31180A03B}</Project>
      <Name>SomeProjectNamespace</Name>
   </ProjectReference>
</ItemGroup>

But when I build the .csproj, it doesn't build the .xproj.

I won't be able to debug .xproj when I run my .csproj, which is bad enough... but at least when I run the .csproj I want to be sure I have the last version of my .xproj compiled.

Upvotes: 1

Views: 439

Answers (1)

natemcmaster
natemcmaster

Reputation: 26823

xproj <=> csproj references in Visual Studio 2015 were always buggy and never worked well. As far as I know, there are no good workarounds.

That said, Visual Studio 2017 RC added support for building .NET Core and .NET Standard with csproj. This deprecates xproj and project.json.

With this new format, a project to project reference would look like this:

<!-- App.csproj -->
<Project Sdk="Microsoft.NET.Sdk">
    <PropertyGroup>
        <OutputType>Exe</OutputType>
        <TargetFramework>net461</TargetFramework>
    </PropertyGroup>
    <ItemGroup>
        <ProjectReference Include="..\Library\Library.csproj" />
    </ItemGroup>
</Project>

<!-- Library.csproj -->
<Project Sdk="Microsoft.NET.Sdk">
    <PropertyGroup>
        <TargetFramework>netstandard1.1</TargetFramework>
    </PropertyGroup>
</Project>

Upvotes: 1

Related Questions