Build/Test Issues

Issue with building some projects from solution.

Started by gorczas on 7,486 views

Hi,

I have downloaded the newest version of nCrunch today and I'm using it with VS 2017. I have solution with 98 projects and few of them are failing because of this error:

NCrunch: This error is commonly caused by projects that are relying on the selected build configuration provided by Visual Studio in order to set the $(Platform) and $(Configuration) MSBuild properties during a build. Unless configured otherwise, NCrunch will normally use the default $(Configuration) and $(Platform) properties that are specified in a .proj file - thus in order for your project to build with NCrunch it must be possible to build the project using command line MSBuild without needing to manually inject build properties. You will most likely need to edit your .proj file to align its default $(Configuration) and $(Platform) properties with the property groups provided in the file. For more information about this problem please refer to http://www.ncrunch.net/documentation/considerations-and-constraints_project-build-platform-and-configuration

I have checked linked workaround and checked my .csproj file and my .csproj file look fine (like the one described in article)

I can post just few bits from this file, but I think that it will be enough.


  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
    <OutputPath>bin\</OutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <Optimize>false</Optimize>
    <DebugType>full</DebugType>
    <DebugSymbols>true</DebugSymbols>
    <PlatformTarget>AnyCPU</PlatformTarget>
    <ErrorReport>prompt</ErrorReport>
    <CodeAnalysisRuleSet>ProjectName.ruleset</CodeAnalysisRuleSet>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
    <OutputPath>bin\</OutputPath>
    <DefineConstants>TRACE</DefineConstants>
    <Optimize>true</Optimize>
    <DebugType>none</DebugType>
    <PlatformTarget>AnyCPU</PlatformTarget>
    <ErrorReport>prompt</ErrorReport>
    <CodeAnalysisRuleSet>ProjectName.ruleset</CodeAnalysisRuleSet>
  </PropertyGroup>
  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <ProductVersion>9.0.30729</ProductVersion>
    <SchemaVersion>2.0</SchemaVersion>
    <ProjectGuid>{62812A0A-352D-4D2C-91C5-F5F058F171D4}</ProjectGuid>
    <ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
    <OutputType>Library</OutputType>
    <AppDesignerFolder>Properties</AppDesignerFolder>
    <RootNamespace>ProjectName</RootNamespace>
    <AssemblyName>ProjectName</AssemblyName>
    <TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
    <OldToolsVersion>4.0</OldToolsVersion>
    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
    <RestorePackages>true</RestorePackages>
  </PropertyGroup>


What can I do to fix this issue?
Hi,

In this case, it looks like the declarations for your configuration and platform have been moved to the bottom of the file, so they are executing too late in MSBuild's evaluation order. Move the bottom-most PropertyGroup to the top of the file and the issue should be resolved.
Remco wrote:Hi,

In this case, it looks like the declarations for your configuration and platform have been moved to the bottom of the file, so they are executing too late in MSBuild's evaluation order. Move the bottom-most PropertyGroup to the top of the file and the issue should be resolved.



THose configuration that I have posted are just after those lines:


<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="CustomConfigTransform;Build" xmlns="(- BROKEN LINK -)" ToolsVersion="12.0">
  <PropertyGroup>
    <UseIISExpress>false</UseIISExpress>
    <ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
    <TargetFrameworkProfile />
    <IISExpressSSLPort />
    <IISExpressAnonymousAuthentication />
    <IISExpressWindowsAuthentication />
    <IISExpressUseClassicPipelineMode />
    <UseGlobalApplicationHostFile />
    <Use64BitIISExpress />
  </PropertyGroup>


So I should move those 3 PropertyGroups from my initial post before this one property group?
This code block should be at the top of your file:

<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
<OutputPath>bin\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<Optimize>false</Optimize>
<DebugType>full</DebugType>
<DebugSymbols>true</DebugSymbols>
<PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>ProjectName.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>


If there's any doubt, try running MSBuild.exe over your project. This is more or less what NCrunch does. When MSBuild can build your project, NCrunch will also be able to.
Thanks,

now it works fine.

Post a reply

Log in to reply.