C# 未为项目设置OutputPath属性

C# 未为项目设置OutputPath属性,c#,msbuild,C#,Msbuild,我有一个在TeamCity成功构建了一年多的解决方案。开发人员向解决方案中添加了两个项目,我们立即收到以下错误: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Microsoft.Common.targets(483,9):未为项目“Compass.Communication.Server.Config.csproj”设置OutputPath属性。请检查以确保为此项目指定了有效的配置和平台组合。配置='DEV'平台='AnyCPU'。您可能会看到

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

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

项目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属性。请检查以确保为此项目指定了有效的配置和平台组合。配置='DEV'平台='AnyCPU'。您可能会看到此消息,因为您试图在没有解决方案文件的情况下构建项目,并且为此项目指定了不存在的非默认配置或平台

我已经尝试了所有我能找到的关于任何CPU与任何CPU以及许多其他东西的方法,但都没有成功。以下是第一个项目的项目文件:

<?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>

调试
任意CPU
8.0.30703
2
{5FC19B70-7DB4-4D8A-B33F-748528E5A042}
图书馆
性质
Compass.Communication.Server.Config
Compass.Communication.Server.Config
v4.0
512
萨克
萨克
萨克
萨克
真的
满的
假的
bin\Debug\
调试;痕迹
促使
4.
bin\Debug\Compass.Communication.Server.Config.XML
任意CPU
pdbonly
真的
bin\Release\
痕迹
促使
4.
{25B8C709-0574-496E-BD1D-5F4DF966F258}
指南针、通信、实体

当您有一个项目未设置为针对活动解决方案配置生成,但被激活的项目引用时,通常会发生这种情况。签入visual studio并确保已将发行版和调试解决方案配置添加到新项目中

几周前,我遇到了一个类似的问题,在我的案例中,问题是由于“任何CPU”之间的空间造成的

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


我也犯了同样的错误

尝试删除“平台”环境变量。


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

刚刚通过在.csproj文件中手动将“AnyCPU”替换为“x64”解决了类似问题:

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

您可以手动将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>

最小推荐规则集
促使
x64
满的
调试;跟踪
bin\x64\Debug\
真的
您还可以按照以下步骤操作:

  • 右键单击解决方案->属性
  • 单击“配置属性”,然后单击“配置管理器”
  • 单击类库的平台下拉列表,然后选择“新建…”
  • 在弹出对话框中,确保新平台为x64,并取消选中“创建新解决方案平台”,然后单击“确定”

  • 您可以将以下内容直接添加到下面的项目文件中

    <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>
    
    
    pdbonly
    真的
    垃圾箱\
    痕迹
    促使
    4.
    
    我不确定您所说的“未设置为为活动解决方案构建的项目”是什么意思“。我检查了Configuration Manager,有问题的两个项目在每个解决方案配置中都适当地出现。虽然我确实认为问题是这样的。你能详细说明你的答案吗?再添加一点关于你提供的解决方案的描述?转到Windows的环境变量,删除名为“平台”的环境变量。(Visual Studio使用此环境变量,该变量的值可能不正确…)绝对twadle,您需要将其中的大部分大写,并且属性组关闭不正确,请参见下文。此外,如果您使用编译器指令,您还需要设置正确的常量定义。遗憾的是,这解决了包括我在内的许多人的问题。您可能认为Microsoft会正确设置默认值。