Build/Test Issues

Nested project imports not copied to NCrunch workspace?

Started by ddewinter on 3,168 views

Hi, I work in an environment where we have .csproj files that import a common targets file (through <Import Project="..." />), and that targets file imports other targets files, and so on. I notice consistently that only the immediately referenced targets file is copied to the NCrunch workspace. Other imports are mysteriously absent.

For the longest time I thought this was default behavior and found ways to work around it, but then I found this thread, which indicates this should not be the case.

I made something simple to repro this.

TestProj.csproj:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="(- BROKEN LINK -)">
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <ProductVersion>8.0.30703</ProductVersion>
    <SchemaVersion>2.0</SchemaVersion>
    <ProjectGuid>{0013C4BD-C4B9-4364-A5CB-8C8C669D5699}</ProjectGuid>
    <OutputType>Library</OutputType>
    <AppDesignerFolder>Properties</AppDesignerFolder>
    <RootNamespace>TestProj</RootNamespace>
    <AssemblyName>TestProj</AssemblyName>
    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
    <FileAlignment>512</FileAlignment>
  </PropertyGroup>
  <Import Project="..\Build.targets" />
  <ItemGroup>
    <Reference Include="System" />
    <Reference Include="System.Core" />
    <Reference Include="System.Xml.Linq" />
    <Reference Include="System.Data.DataSetExtensions" />
    <Reference Include="Microsoft.CSharp" />
    <Reference Include="System.Data" />
    <Reference Include="System.Xml" />
  </ItemGroup>
  <ItemGroup>
    <Compile Include="Class1.cs" />
    <Compile Include="Properties\AssemblyInfo.cs" />
  </ItemGroup>
  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>


..\Build.targets (copied to NCrunch):

<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="(- BROKEN LINK -)">

  <PropertyGroup>
    <MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
  </PropertyGroup>

  <Import Project="build\Build.targets" />

</Project>


build\Build.targets (not copied):
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="(- BROKEN LINK -)">

  <PropertyGroup>
    <MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
    <OutDir>..\bin</OutDir>
  </PropertyGroup>

    <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <DebugSymbols>true</DebugSymbols>
    <DebugType>full</DebugType>
    <Optimize>false</Optimize>
    <OutputPath>$(OutDir)\Debug\</OutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <DebugType>pdbonly</DebugType>
    <Optimize>true</Optimize>
    <OutputPath>$(OutDir)\Release\</OutputPath>
    <DefineConstants>TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>

</Project>


Any ideas?

Thanks,
David
Hi David,

Thanks for posting!

This is a known issue for which so far no reliable solution has been found. You can work around the problem by using the 'Additional files to include' setting to include the build files that are required by the included import.

Thanks for sharing the reproduction above - I'll see if I can make use of it when trying to solve the issue.


Cheers,

Remco

Post a reply

Log in to reply.