繁体   English   中英

在VSTS上使用GAC_MSIL程序集的错误

[英]Errors using GAC_MSIL assemblies on VSTS

我有一个存储在VSTS中的ASP Web表单项目,我正在尝试构建它。 突然,我在构建部分遇到了这个错误:

2017-04-18T22:01:20.3859517Z Build FAILED.
2017-04-18T22:01:20.3859517Z 
2017-04-18T22:01:20.3869498Z "d:\a\1\s\WebTimeSheet.sln" (default target) (1) ->
2017-04-18T22:01:20.3869498Z "d:\a\1\s\WebTimeSheet\WebTimeSheet.csproj" (default target) (2) ->
2017-04-18T22:01:20.3869498Z (ResolveComReferences target) -> 
2017-04-18T22:01:20.3869498Z   C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets(2399,5): warning MSB3284: Cannot get the file path for type library "2df8d04c-5bfa-101b-bde5-00aa0044de52" version 2.5. Library not registered. (Exception from HRESULT: 0x8002801D (TYPE_E_LIBNOTREGISTERED)) [d:\a\1\s\WebTimeSheet\WebTimeSheet.csproj]
2017-04-18T22:01:20.3869498Z   C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets(2399,5): warning MSB3284: Cannot get the file path for type library "00020813-0000-0000-c000-000000000046" version 1.7. Library not registered. (Exception from HRESULT: 0x8002801D (TYPE_E_LIBNOTREGISTERED)) [d:\a\1\s\WebTimeSheet\WebTimeSheet.csproj]
2017-04-18T22:01:20.3869498Z   C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets(2399,5): warning MSB3284: Cannot get the file path for type library "00020905-0000-0000-c000-000000000046" version 8.5. Library not registered. (Exception from HRESULT: 0x8002801D (TYPE_E_LIBNOTREGISTERED)) [d:\a\1\s\WebTimeSheet\WebTimeSheet.csproj]
2017-04-18T22:01:20.3869498Z   C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets(2399,5): warning MSB3284: Cannot get the file path for type library "0002e157-0000-0000-c000-000000000046" version 5.3. Library not registered. (Exception from HRESULT: 0x8002801D (TYPE_E_LIBNOTREGISTERED)) [d:\a\1\s\WebTimeSheet\WebTimeSheet.csproj]
2017-04-18T22:01:20.4149496Z 
2017-04-18T22:01:20.4149496Z 
2017-04-18T22:01:20.4149496Z "d:\a\1\s\WebTimeSheet.sln" (default target) (1) ->
2017-04-18T22:01:20.4149496Z "d:\a\1\s\WebTimeSheet\WebTimeSheet.csproj"     (default target) (2) ->
2017-04-18T22:01:20.4149496Z (CoreCompile target) -> 
2017-04-18T22:01:20.4149496Z   Helpers\ExcelDataBuilder.cs(6,17): error CS0234: The type or namespace name 'Office' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?) [d:\a\1\s\WebTimeSheet\WebTimeSheet.csproj]
2017-04-18T22:01:20.4149496Z   Helpers\WordInvoiceBuilder.cs(5,17): error CS0234: The type or namespace name 'Office' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?) [d:\a\1\s\WebTimeSheet\WebTimeSheet.csproj]
2017-04-18T22:01:20.4149496Z   Helpers\ExcelDataBuilder.cs(127,104): error CS0246: The type or namespace name 'Worksheet' could not be found (are you missing a using directive or an assembly reference?) [d:\a\1\s\WebTimeSheet\WebTimeSheet.csproj]
2017-04-18T22:01:20.4149496Z   Helpers\ExcelDataBuilder.cs(166,80): error CS0246: The type or namespace name 'Worksheet' could not be found (are you missing a using directive or an assembly reference?) [d:\a\1\s\WebTimeSheet\WebTimeSheet.csproj]
2017-04-18T22:01:20.4149496Z   Helpers\ExcelDataBuilder.cs(18,17): error CS0246: The type or namespace name 'Application' could not be found (are you missing a using directive or an assembly reference?) [d:\a\1\s\WebTimeSheet\WebTimeSheet.csproj]
2017-04-18T22:01:20.4149496Z   Helpers\WordInvoiceBuilder.cs(172,143): error CS0246: The type or namespace name 'Document' could not be found (are you missing a using directive or an assembly reference?) [d:\a\1\s\WebTimeSheet\WebTimeSheet.csproj]
2017-04-18T22:01:20.4149496Z   Helpers\WordInvoiceBuilder.cs(19,17): error CS0246: The type or namespace name 'Application' could not be found (are you missing a using directive or an assembly reference?) [d:\a\1\s\WebTimeSheet\WebTimeSheet.csproj]
2017-04-18T22:01:20.4149496Z 
2017-04-18T22:01:20.4149496Z     4 Warning(s)
2017-04-18T22:01:20.4149496Z     7 Error(s)

我正在使用Hosted Queue来构建项目。 我试图获得asemblies的本地副本,将它们包含在项目(/ bin)中并上传它们,但它不起作用。 ¿如何将它们包含在构建中以便我可以避免此错误?

如果我使用Visual Studio Community 2015在本地构建项目,则工作正常(aseemblies已包含在引用中)。

我没有私人代理(只使用托管)。 我的构建配置是默认构建。 其他任何标志都是默认的。 NuGet恢复,.sln根路径,默认Visual Studio构建和没有测试程序集。

对不起,如果我忘了别的话。

非常感谢,

好吧,经过一番深入的研究,我终于明白了。 我分两步解决了这个问题:

第一步。 我已将dll包含在** \\ bin \\文件夹中。 这些dll是GAC嵌入式程序集的一部分,因此获取它们的方法是参见本文

从GAC中获取DLL

一旦部署在GAC(通常位于c:\\ windows \\ assembly)中的DLL就无法查看或用作普通的DLL文件。 它们不能直接从VS项目中引用。 开发人员通常会保留原始DLL文件的副本,并在开发(设计)时在项目中引用它,该文件在项目运行期间使用GAC中的程序集。

在执行(运行时)期间,如果发现程序集在GAC中被签名和部署,则CLR会自动从GAC中获取程序集,而不是在VS中设计时引用的DLL。 如果开发人员删除了原始DLL或由于某种原因没有它,有一种方法可以从GAC获取DLL文件。 按照以下步骤从GAC复制DLL

  1. 运行regsvr32 / u C:\\ WINDOWS \\ Microsoft.NET \\ Framework \\ v2.0.50727 \\ shfusion.dll

    • shfusion.dll是一个资源管理器扩展DLL,它为GAC文件夹提供了独特的外观。 取消注册此文件将删除程序集缓存查看器,然后GAC文件夹将显示为资源管理器中的任何普通文件夹。

      1. 打开“%windir%\\ assembly \\ GAC_MSIL”。
      2. 浏览到你的DLL文件夹深入找到你的DLL。
      3. 将DLL复制到硬盘上的某个位置,并从项目中的那里引用它
      4. 运行“regsvr32%windir%\\ Microsoft.NET \\ Framework \\ <。NET版目录> \\ shfusion.dll”以重新注册shfusion.dll文件并重新获得GAC的原始独特视图。

或者,您可以直接通过命令行(CMD)获取它们

CMD “C:\\ Windows \\ assembly \\ GAC_MSIL”

之后我将它们上传到我的项目中。

第二步。 我修改了我的构建过程添加测试程序集(** \\ bin * .dll)。

此外,我修改了2017年至2015年的视觉工作室版本(实际上并没有改变任何东西)。

也许有一个更好的方法,我只是找到了解决它的方法(显然)。

新的VSTS输出日志(FYI)

2017-04-19T09:29:15.1691631Z Done Building Project "d:\a\1\s\WebTimeSheet\WebTimeSheet.csproj" (default targets).
2017-04-19T09:29:15.1701644Z Done Building Project "d:\a\1\s\WebTimeSheet.sln" (default targets).
2017-04-19T09:29:15.1721645Z 
2017-04-19T09:29:15.1721645Z Build succeeded.
2017-04-19T09:29:15.1841654Z 
2017-04-19T09:29:15.1841654Z "d:\a\1\s\WebTimeSheet.sln" (default target) (1) ->
2017-04-19T09:29:15.1841654Z "d:\a\1\s\WebTimeSheet\WebTimeSheet.csproj" (default target) (2) ->
2017-04-19T09:29:15.1841654Z (ResolveComReferences target) -> 
2017-04-19T09:29:15.1841654Z   C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets(2399,5): warning MSB3284: Cannot get the file path for type library "2df8d04c-5bfa-101b-bde5-00aa0044de52" version 2.5. Library not registered. (Exception from HRESULT: 0x8002801D (TYPE_E_LIBNOTREGISTERED)) [d:\a\1\s\WebTimeSheet\WebTimeSheet.csproj]
2017-04-19T09:29:15.1841654Z   C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets(2399,5): warning MSB3284: Cannot get the file path for type library "0002e157-0000-0000-c000-000000000046" version 5.3. Library not registered. (Exception from HRESULT: 0x8002801D (TYPE_E_LIBNOTREGISTERED)) [d:\a\1\s\WebTimeSheet\WebTimeSheet.csproj]
2017-04-19T09:29:15.1841654Z 
2017-04-19T09:29:15.1841654Z     2 Warning(s)
2017-04-19T09:29:15.1841654Z     0 Error(s)
2017-04-19T09:29:15.1841654Z 
2017-04-19T09:29:15.1851621Z Time Elapsed 00:00:10.59
2017-04-19T09:29:15.2201873Z ##[section]Finishing: Build solution

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM