简体   繁体   English

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

[英]Errors using GAC_MSIL assemblies on VSTS

I have an ASP web form Project stored in VSTS, and I am trying to build it. 我有一个存储在VSTS中的ASP Web表单项目,我正在尝试构建它。 Suddenly I got this error in the build section: 突然,我在构建部分遇到了这个错误:

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)

I am using Hosted Queue to build the project. 我正在使用Hosted Queue来构建项目。 I have tried to get a local copy of the asemblies, include them into the project (/bin) and upload them, but it does not work. 我试图获得asemblies的本地副本,将它们包含在项目(/ bin)中并上传它们,但它不起作用。 ¿How Can I include them into the build so I can avoid this error? ¿如何将它们包含在构建中以便我可以避免此错误?

If I build the project in my local using Visual Studio Community 2015, works fine (the aseemblies are already included in references). 如果我使用Visual Studio Community 2015在本地构建项目,则工作正常(aseemblies已包含在引用中)。

I have no private agents (just using Hosted). 我没有私人代理(只使用托管)。 My build configuration was default build. 我的构建配置是默认构建。 Everythign else by defaul. 其他任何标志都是默认的。 NuGet restore, .sln root path, default visual studio build and no test assemblies. NuGet恢复,.sln根路径,默认Visual Studio构建和没有测试程序集。

Sorry if I forgot something else. 对不起,如果我忘了别的话。

Many thanks, 非常感谢,

Well, after some in-depth research, I finally got it. 好吧,经过一番深入的研究,我终于明白了。 I solved it in two steps: 我分两步解决了这个问题:

First Step. 第一步。 I have included the dll's in the **\\bin\\ folder. 我已将dll包含在** \\ bin \\文件夹中。 These dll's are part of GAC embeded assembly, so the way to get them is See this article 这些dll是GAC嵌入式程序集的一部分,因此获取它们的方法是参见本文

Get DLL Out of The GAC 从GAC中获取DLL

DLLs once deployed in GAC (normally located at c:\\windows\\assembly) can't be viewed or used as a normal DLL file. 一旦部署在GAC(通常位于c:\\ windows \\ assembly)中的DLL就无法查看或用作普通的DLL文件。 They can't be directly referenced from VS project. 它们不能直接从VS项目中引用。 Developers usually keep a copy of the original DLL file and refer to it in the project at development (design) time, which uses the assembly from GAC during run-time of the project. 开发人员通常会保留原始DLL文件的副本,并在开发(设计)时在项目中引用它,该文件在项目运行期间使用GAC中的程序集。

During execution (run-time) if the assembly is found to be signed and deployed in GAC the CLR automatically picks up the assembly from the GAC instead of the DLL referenced during design time in VS. 在执行(运行时)期间,如果发现程序集在GAC中被签名和部署,则CLR会自动从GAC中获取程序集,而不是在VS中设计时引用的DLL。 In case the developer has deleted the original DLL or don't have it for some reason, there is a way to get the DLL file from GAC. 如果开发人员删除了原始DLL或由于某种原因没有它,有一种方法可以从GAC获取DLL文件。 Follow the following steps to copy DLL from GAC 按照以下步骤从GAC复制DLL

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

    • shfusion.dll is an explorer extension DLL that gives a distinct look to the GAC folder. shfusion.dll是一个资源管理器扩展DLL,它为GAC文件夹提供了独特的外观。 Unregistering this file will remove the assembly cache viewer and the GAC folder will be then visible as any normal folder in explorer. 取消注册此文件将删除程序集缓存查看器,然后GAC文件夹将显示为资源管理器中的任何普通文件夹。

      1. Open “%windir%\\assembly\\GAC_MSIL”. 打开“%windir%\\ assembly \\ GAC_MSIL”。
      2. Browse to your DLL folder into the deep to find your DLL. 浏览到你的DLL文件夹深入找到你的DLL。
      3. Copy the DLL somewhere on your hard disk and refer it from there in your project 将DLL复制到硬盘上的某个位置,并从项目中的那里引用它
      4. Run "regsvr32 %windir%\\Microsoft.NET\\Framework\\<.NET version directory> \\shfusion.dll" to re-register the shfusion.dll file and regain the original distinct view of the GAC. 运行“regsvr32%windir%\\ Microsoft.NET \\ Framework \\ <。NET版目录> \\ shfusion.dll”以重新注册shfusion.dll文件并重新获得GAC的原始独特视图。

Alternatively you can get them through command line (CMD) directly 或者,您可以直接通过命令行(CMD)获取它们

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

After that I uploaded them into my project. 之后我将它们上传到我的项目中。

Second Step. 第二步。 I have modifed my build process adding Test assemblies (**\\bin*.dll). 我修改了我的构建过程添加测试程序集(** \\ bin * .dll)。

Also I modifed visual studio version from 2017 to 2015 (which actually does not change anything). 此外,我修改了2017年至2015年的视觉工作室版本(实际上并没有改变任何东西)。

Maybe there is a better approach, I have simply found a way to fix it (apparently). 也许有一个更好的方法,我只是找到了解决它的方法(显然)。

New VSTS output Log (FYI) 新的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