【问题标题】:Is it possible to use Portable Class Libraries(PCL) with Visual Studio Online hosted build server?是否可以将可移植类库(PCL)与 Visual Studio Online 托管的构建服务器一起使用?
【发布时间】:2015-10-29 10:03:21
【问题描述】:

我正在尝试使用 Visual Studio Online 中的 Hosted Builder 服务器。 我正在使用 Visual Studio 2015。

在我包含可移植类库 (PCL) 之前,一切正常。 我收到与 AssemblyInfo.cs 文件相关的错误:

Source\TestprojectSolution\TestprojectPCL\Properties\AssemblyInfo.cs (9, 12)
        The type or namespace name 'AssemblyTitle' could not be found (are you missing a using directive or an assembly reference?)
    Source\TestprojectSolution\TestprojectPCL\Properties\AssemblyInfo.cs (10, 12)
    The type or namespace name 'AssemblyDescription' could not be found (are you missing a using directive or an assembly reference?)
    Source\TestprojectSolution\TestprojectPCL\Properties\AssemblyInfo.cs (11, 12)
    The type or namespace name 'AssemblyConfiguration' could not be found (are you missing a using directive or an assembly reference?)
    Source\TestprojectSolution\TestprojectPCL\Properties\AssemblyInfo.cs (12, 12)
    The type or namespace name 'AssemblyCompany' could not be found (are you missing a using directive or an assembly reference?)
    Source\TestprojectSolution\TestprojectPCL\Properties\AssemblyInfo.cs (13, 12)
    The type or namespace name 'AssemblyProduct' could not be found (are you missing a using directive or an assembly reference?)
    Source\TestprojectSolution\TestprojectPCL\Properties\AssemblyInfo.cs (14, 12)
    The type or namespace name 'AssemblyCopyright' could not be found (are you missing a using directive or an assembly reference?)
    Source\TestprojectSolution\TestprojectPCL\Properties\AssemblyInfo.cs (15, 12)
    The type or namespace name 'AssemblyTrademark' could not be found (are you missing a using directive or an assembly reference?)
    Source\TestprojectSolution\TestprojectPCL\Properties\AssemblyInfo.cs (16, 12)
    The type or namespace name 'AssemblyCulture' could not be found (are you missing a using directive or an assembly reference?)
    Source\TestprojectSolution\TestprojectPCL\Properties\AssemblyInfo.cs (17, 12)
    The type or namespace name 'NeutralResourcesLanguage' could not be found (are you missing a using directive or an assembly reference?)
    Source\TestprojectSolution\TestprojectPCL\Properties\AssemblyInfo.cs (29, 12)
    The type or namespace name 'AssemblyVersion' could not be found (are you missing a using directive or an assembly reference?)

是否可以将 PCL 与托管构建服务器一起使用?如果是这样,我该怎么做?

【问题讨论】:

  • 打开AssemblyInfo.cs文件,右击[assembly: AssemblyTitle("name")]行中的AssemblyTitle属性并选择'Go to definition',请检查引用了哪个程序集.
  • 我和蒂姆有同样的问题,所以如果可以的话:去定义对我来说会产生以下结果:Assembly System.Runtime, Version=4.0.20.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a (local路径:.nuget\packages\System.Runtime\4.0.20\ref\dotnet\System.Runtime.dll)
  • 对不起,我不得不删除 PCL 并用普通的类库替换它。不过还是没有头绪……
  • 很想听听答案,Vicky。这里同样的问题。 Resharper 将我带到: // 使用 JetBrains 反编译器进行反编译 // 类型:System.Reflection.AssemblyTitleAttribute // 程序集:mscorlib,Version=4.0.0.0,Culture=neutral,PublicKeyToken=b77a5c561934e089 // MVID:60C8914F-EAF9-4641-8F9D -EEA81508716F // 组装位置:C:\Windows\Microsoft.NET\Framework\v4.0.30319\mscorlib.dll

标签: tfsbuild portable-class-library azure-devops


【解决方案1】:

我刚刚在这里回答了这个问题:https://stackoverflow.com/a/33571729/1123431

发生这种情况的原因是构建代理上的 NuGet 版本不足以从project.json 文件生成project.lock.json 文件。在 Microsoft 更新其默认服务器上的 NuGet 版本之前,我们只需将project.lock.json 文件与我们的项目一起签入。

【讨论】:

    【解决方案2】:

    我找到了问题的解决方案,但不确定每个人都一样。

    我的项目是使用 VS2013 创建的,并且我启用了自动 nuget 还原。在 VS2013 中,您会在项目文件中获得一个 .nuget 解决方案文件夹和一些 xml 代码。 这是在 msbuild 期间恢复 nuget 包的“旧方式”。

    xml 代码在你的 cproj 文件的底部附近,它应该看起来像这样:

    <Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
      <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
        <PropertyGroup>
          <ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them.  For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
        </PropertyGroup>
        <Error Condition="!Exists('$(SolutionDir)\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.targets'))" />
      </Target>
    

    从项目文件中删除此解决方案文件夹和 xml 代码(您必须先卸载项目)解决了我的问题。

    查看更多信息: https://docs.nuget.org/consume/package-restore#automatic-package-restore-in-visual-studio (他们在顶部清楚地说,不要混合新旧样式;-))

    我希望这会有所帮助!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-10-08
      • 2011-05-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-10-19
      • 2014-11-05
      相关资源
      最近更新 更多