Visual Studio 2012无法构建引用其他项目的新项目

时间:2013-07-26 18:50:41

标签: c# .net-4.0 reference project csproj

我有一个已经工作了几年的解决方案。今天我在不断发展的几个月里第一次添加了一个新项目。一切都很好,编码。去构建并发现它找不到我添加的任何项目引用。

  

类型或命名空间名称' blah'找不到(你错过了使用direcive或汇编引用吗?)

这些引用是针对同一解决方案中的项目,并验证它们是CSPROJ文件中的项目引用。 Visual Studio找到引用没有问题,因为我可以很好地对引用的对象进行编码。只有当我构建我有问题时才会这样做。目前正在使用AnyCPU进行调试。

进行谷歌搜索,我不断发现问题可能是目标框架是我的新项目或参考文献中的.NET 4 Client Profile。然而,这种情况并非如此。所有项目都是.NET 4,而不是客户端配置文件(我已经验证)。更奇怪的是,这些引用在现有项目中都运行良好。

如果我创建新的.NET 4.5项目让我觉得.NET 4的目标框架出了问题,我可以构建它。我目前迷失了,不知道该怎么做。

以下是项目文件。我必须清除文件名和项目名称。

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <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>
    <ProjectGuid>{48AED04F-6928-45F4-8C1D-A5E6713B5120}</ProjectGuid>
    <OutputType>Library</OutputType>
    <AppDesignerFolder>Properties</AppDesignerFolder>
    <RootNamespace>MyNamespace</RootNamespace>
    <AssemblyName>MyNamespace</AssemblyName>
    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
    <FileAlignment>512</FileAlignment>
    <TargetFrameworkProfile />
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <DebugSymbols>true</DebugSymbols>
    <DebugType>full</DebugType>
    <Optimize>false</Optimize>
    <OutputPath>..\Build\Debug\</OutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
    <Prefer32Bit>false</Prefer32Bit>
  </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>
    <Prefer32Bit>false</Prefer32Bit>
  </PropertyGroup>
  <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="SomeFileThatReferences.cs" />
    <Compile Include="Properties\AssemblyInfo.cs" />
  </ItemGroup>
  <ItemGroup>
    <ProjectReference Include="..\Ref1.csproj">
      <Project>{6E0EEABF-52D7-4020-9242-AFDC33B5DAA0}</Project>
      <Name>Billing.Bills</Name>
    </ProjectReference>
    <ProjectReference Include="..\Ref2.csproj">
      <Project>{6764A403-DA4C-42FF-A89F-E1EEA7FEF0A3}</Project>
      <Name>Billing.Business</Name>
    </ProjectReference>
    <ProjectReference Include="..\Ref3.csproj">
      <Project>{9D9AB79F-D52A-4EC8-B2B7-9C605EFDBFDE}</Project>
      <Name>Billing.Reports</Name>
    </ProjectReference>
    <ProjectReference Include="..\Csla\Csla.Net4\Csla.Net4.csproj">
      <Project>{1FCE45FF-C391-4ED1-A9C4-F71CAF8773E6}</Project>
      <Name>Csla.Net4</Name>
    </ProjectReference>
    <ProjectReference Include="..\Ref4.csproj">
      <Project>{3972242B-DF6A-4B9B-9121-6138090CA114}</Project>
      <Name>Core</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>

提前感谢任何答案/建议。

2 个答案:

答案 0 :(得分:2)

想出来。显然我错过了一个我不知道的参考文献。所有其他项目都引用了Microsoft的BCL Portability Pack。一旦我在NuGet中看到它并且除了新的项目之外所有项目都有它,我立即引用它,现在一切都在构建。

这是一个有趣的幽灵狩猎。

答案 1 :(得分:0)

这个恼人的错误的另一个原因。通过查看警告消息找到了这个。构建时的错误消息没有提供所需的信息:

  

警告6主要参考“C:.. path-to-you-solution-ref .dll”   无法解决,因为它建立在反对   “.NETFramework,Version = v4.5.1”框架。这是一个更高的版本   比目前的目标框架“.NETFramework,Version = v4.5”。

由于我正在干净安装VStudio,看起来默认项目尚未设置为更高版本。因此,版本差异(引用较低版本的较高版本)将执行此操作。

相关问题