警告: 所有引用 MyProject.csproj 的项目必须安装 nuget 包 Microsoft.Bcl.Build

我有一个 ASP.NET MVC 4应用程序在 VS 2012开发。该应用程序由一个主项目(MyProject)、一个单元测试项目(MyProject)组成。一个 Azure 部署项目(MyProject)。Azure) ,以及一些通用图书馆项目。

当我右键单击解决方案或主项目并选择 Manage NuGet Packages 时,我会看到一系列微软的更新,这些更新显然是在上个月左右开始可用的。如果我点击更新所有按钮,然后更新显然安装没有任何明显的问题,但当我建立的解决方案,我得到这个错误消息两次:

warning : All projects referencing MyProject.csproj must install nuget package Microsoft.Bcl.Build

好的,我有两个参考 MyProject 的项目: MyProject。测试和我的项目。天蓝色。我可以右键单击 MyProject。测试,选择 ManageNuGetPackages,并添加 Microsoft。Bcl.建造。这样就消除了两个警告中的一个。但是 VS 没有给我一个为 MyProject.Azure 项目管理 NuGet 包的选项

如何将 Microsoft.Bcl.Build 包添加到 Azure 部署项目中?

编辑:

感谢用户 好极了,我现在知道这个问题的 MicrosoftConnect 问题已经打开了 给你

35204 次浏览

If you double click the warning it gives you instructions for disabling the warning.

It is safe to disable for projectreferences from projects that don't yet support Nuget.

See below portion in bold copied from Microsoft.Bcl.Build.targets.

BclBuildValidateNugetPackageReferences

This target can be disabled for a project reference by setting SkipValidatePackageReferences=true for the reference:

<ProjectReference Include="..\pcl\pcl.csproj">
<Project>{664a9e98-fac7-4567-a046-0dde95fddb48}</Project>
<Name>pcl</Name>
<Properties>SkipValidatePackageReferences=true</Properties>
</ProjectReference>

I faced the same issue and was trying to update Microsoft.Bcl.Build.targets; which did not help.

After some investigation found that .csproj file of the Azure Service project must be modified to include <Properties>SkipValidatePackageReferences=true</Properties>.

This was not apparent from the answer of @TheESJ and so decided to post separate answer. Thanks to @TheESJ.

The answer provided by TheESJ is correct, however the wording wasn't clear to me. Since I cannot comment on the answer, I will provide more details here. Specifically, I was having this problem with an Azure project and the following workaround was required to make the warning go away:

When you double-click the warning in VisualStudio, you will be taken to the BclBuildValidateNugetPackageReferences target in the Microsoft.BclBuild.targets file. Above the actual target element, you should find a large comment block that talks about disabling the project reference checks. Since Azure projects cannot have any library references, it is impossible for those Azure projects to fulfill the requirements of this particular build target.

The solution? Disable reference checking from the Azure project since it is impossible to actually add a nuget package reference.

EXAMPLE

So, assume we have two projects: MyAzureProject.ccproj which references MyProject.csproj. Follow these steps:

  1. Right-click on "MyAzureProject" in the Solution Explorer and select "Edit Project File."
  2. Find the project reference to "MyProject." It should look something like:

    <ProjectReference Include="..\MyProject\MyProject.csproj">
    <Name>MyProject</Name>
    <Project>{1d99490e-d140-4897-9890-238e673a5864}</Project>
    ...
    </ProjectReference>
    
  3. Add the following element inside of the ProjectReference element:

      <Properties>SkipValidatePackageReferences=true</Properties>
    
  4. Your project reference should now look like this:

    <ProjectReference Include="..\MyProject\MyProject.csproj">
    <Name>MyProject</Name>
    <Project>{1d99490e-d140-4897-9890-238e673a5864}</Project>
    ...
    <Properties>SkipValidatePackageReferences=true</Properties>
    </ProjectReference>
    
  5. Right-click on "MyAzureProject" in Solution Explorer and choose "Reload Project."

You should now be able to rebuild and the error should be gone.

I encountered this issue a number of times, and the Properties method does indeed work, but when dealing with a Wix project, I had to do the following instead:

<AdditionalProperties>SkipValidatePackageReferences=true</AdditionalProperties>

When I used the Properties Xml node, I got a new error:

The OutputPath property is not set for project 'MyInstallerProject.csproj'. Please check to make sure that you have specified a valid combination of Configuration and Platform for this project. Configuration='Debug' Platform='x86'. This error may also appear if some other project is trying to follow a project-to-project reference to this project, this project has been unloaded or is not included in the solution, and the referencing project does not build using the same or an equivalent Configuration or Platform.

After failing to resolve the issues with any of the above answers, I simply followed the instructions contained within the Microsoft.Bcl.Build.targets file (displayed after double clicking on the error in the build output window). I unloaded my project (referencing Azure packages), encountering the error. Edited the project file and inserted the following...

<PropertyGroup>
<SkipValidatePackageReferences>true</SkipValidatePackageReferences>
</PropertyGroup>

...at the top of the project file before the first PropertyGroup.