未为项目设置OutputPath属性

时间:2014-01-02 20:26:25

标签: c# msbuild

我有一个已在Team City成功建立一年多的解决方案。开发人员在解决方案中添加了两个项目,并立即收到以下错误:

C:\ Windows \ Microsoft.NET \ Framework64 \ v4.0.30319 \ Microsoft.Common.targets(483,9):未为项目“Compass.Communication.Server.Config.csproj”设置OutputPath属性。请检查以确保您为此项目指定了Configuration和Platform的有效组合。 Configuration ='DEV'Platform ='AnyCPU'。您可能会看到此消息,因为您正在尝试构建没有解决方案文件的项目,并且已指定了此项目不存在的非默认配置或平台。

Project Compass.Communication.Server.Config \ Compass.Communication.Server.Config.csproj失败。   C:\ Windows \ Microsoft.NET \ Framework64 \ v4.0.30319 \ Microsoft.Common.targets(483,9):没有为项目'Compass.Communication.Server.Processor.csproj'设置OutputPath属性。请检查以确保您为此项目指定了Configuration和Platform的有效组合。 Configuration ='DEV'Platform ='AnyCPU'。您可能会看到此消息,因为您正在尝试构建没有解决方案文件的项目,并且已指定了此项目不存在的非默认配置或平台。

我已经尝试了大多数关于任何CPU与AnyCPU以及许多其他没有成功的东西。这是第一个项目的项目文件:

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <ProductVersion>8.0.30703</ProductVersion>
    <SchemaVersion>2.0</SchemaVersion>
    <ProjectGuid>{5FC19B70-7DB4-4D8A-B33F-748528E5A042}</ProjectGuid>
    <OutputType>Library</OutputType>
    <AppDesignerFolder>Properties</AppDesignerFolder>
    <RootNamespace>Compass.Communication.Server.Config</RootNamespace>
    <AssemblyName>Compass.Communication.Server.Config</AssemblyName>
    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
    <FileAlignment>512</FileAlignment>
    <SccProjectName>SAK</SccProjectName>
    <SccLocalPath>SAK</SccLocalPath>
    <SccAuxPath>SAK</SccAuxPath>
    <SccProvider>SAK</SccProvider>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <DebugSymbols>true</DebugSymbols>
    <DebugType>full</DebugType>
    <Optimize>false</Optimize>
    <OutputPath>bin\Debug\</OutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
    <DocumentationFile>bin\Debug\Compass.Communication.Server.Config.XML</DocumentationFile>
    <PlatformTarget>AnyCPU</PlatformTarget>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <DebugType>pdbonly</DebugType>
    <Optimize>true</Optimize>
    <OutputPath>bin\Release\</OutputPath>
    <DefineConstants>TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>
  <ItemGroup>
    <Reference Include="System" />
    <Reference Include="System.configuration" />
    <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="CommunicationConditionalElement.cs" />
    <Compile Include="CommunicationConditionalSection.cs" />
    <Compile Include="CommunicationConfigurationManager.cs" />
    <Compile Include="CommunicationCriterionElement.cs" />
    <Compile Include="CommunicationCriterionSection.cs" />
    <Compile Include="CommunicationElementExtensions.cs" />
    <Compile Include="CommunicationIntroductionElement.cs" />
    <Compile Include="CommunicationIntroductionSection.cs" />
    <Compile Include="CommunicationSectionElement.cs" />
    <Compile Include="CommunicationSectionSection.cs" />
    <Compile Include="CommunicationTypeElement.cs" />
    <Compile Include="CommunicationTypeSection.cs" />
    <Compile Include="GenericConfigurationElementCollection.cs" />
    <Compile Include="RefElement.cs" />
    <Compile Include="Properties\AssemblyInfo.cs" />
  </ItemGroup>
  <ItemGroup>
    <ProjectReference Include="..\Compass.Communication.Entities\Compass.Communication.Entities.csproj">
      <Project>{25B8C709-0574-496E-BD1D-5F4DF966F258}</Project>
      <Name>Compass.Communication.Entities</Name>
    </ProjectReference>
  </ItemGroup>
  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
  <!-- 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>

6 个答案:

答案 0 :(得分:10)

几周之前我遇到过类似的问题,在我的情况下问题是由于“任何CPU”之间的空间造成的。

您需要确保“AnyCPU”在您的构建定义中的任何位置都不包含任何空格。

此致

答案 1 :(得分:1)

您可以将以下内容直接添加到

项目文件中
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'"> 
    <DebugType>pdbonly</DebugType>
    <Optimize>true</Optimize>
    <OutputPath>bin\</OutputPath>
    <DefineConstants>TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel> 
</PropertyGroup>

答案 2 :(得分:0)

当您的项目未设置为活动解决方案配置构建但由项目引用时,通常会发生这种情况。检查visual studio并确保已将发布和调试解决方案配置添加到新项目中。

答案 3 :(得分:0)

我有同样的错误。

尝试删除&#34;平台&#34;环境变量。

然后重新启动VS,并构建您的解决方案......

答案 4 :(得分:0)

通过在.csproj文件中用“x64”手动替换“AnyCPU”来解决类似的问题:

<Platform Condition=" '$(Platform)' == '' ">x64</Platform\>

答案 5 :(得分:0)

您可以手动将OutputPath属性插入DLL类库的proj文件中。下面是一个片段/示例,说明它的用途。

<propertygroup condition="'$(Configuration)|$(Platform)' == 'Release|x64'"> 
</propertygroup> 
<codeanalysisruleset>MinimumRecommendedRules.ruleset</codeanalysisruleset>
<errorreport>prompt</errorreport>
<platformtarget>x64</platformtarget>
<debugtype>full</debugtype>
<defineconstants>DEBUG;TRACE</defineconstants>
<outputpath>bin\x64\Debug\</outputpath>
<debugsymbols>true</debugsymbols>

您也可以按照以下步骤操作:

  1. 右键点击解决方案 - &gt;特性
  2. 单击“配置属性”,然后单击“配置管理器”
  3. 单击类库的平台下拉列表,然后选择“new ...”
  4. 在弹出对话框中,确保New platform为x64,取消选中“Create new solutions platforms”,然后单击OK