PostSharp not building on TeamCity: Cannot find assembly mscorlib

蓝咒 提交于 2020-01-05 07:18:43

问题


PostSharp will build on local dev machine, it will not build on the TeamCity server, the error is:

unknown error PS0264: Cannot find assembly 'mscorlib, version=2.0.5.0, culture=neutral, publickeytoken=7cec85d7bea7798e'.

Here is an excerpt from the build log:

[13:38:22][PostSharp30] Merging assembly binding policy files.
[13:38:22][PostSharp30] Executing "C:\ProgramData\PostSharp\5.0.43\bin.Release\postsharp-net40-x86-native.exe" <REMOVED SENSITIVE INFORMATION>
[13:38:25][PostSharp30] unknown : verbose PS0265: Detailed log for the next error:
[13:38:25][PostSharp30] unknown : verbose PS0265: LOG: Finding reference assembly with binding identity 'mscorlib, version=2.0.5.0, culture=neutral, publickeytoken=7cec85d7bea7798e' in the Reference context.
[13:38:25][PostSharp30] unknown : verbose PS0265: LOG:  Found file 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\mscorlib.dll', identity='mscorlib, version=4.0.0.0, culture=neutral, publickeytoken=b77a5c561934e089', ProcessorArchitecture=NoPlatform.
[13:38:25][PostSharp30] unknown : verbose PS0265: LOG:  Reference mismatch for 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\mscorlib.dll' [PublicKeyMismatch].
[13:38:25][PostSharp30] unknown : verbose PS0265: LOG:  Found file 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\mscorlib.dll', identity='mscorlib, version=4.0.0.0, culture=neutral, publickeytoken=b77a5c561934e089', ProcessorArchitecture=NoPlatform.
[13:38:25][PostSharp30] unknown : verbose PS0265: LOG:  Reference mismatch for 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\mscorlib.dll' [PublicKeyMismatch].
[13:38:25][PostSharp30] unknown : verbose PS0265: LOG:  Found file 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\mscorlib.dll', identity='mscorlib, version=4.0.0.0, culture=neutral, publickeytoken=b77a5c561934e089', ProcessorArchitecture=NoPlatform.
[13:38:25][PostSharp30] unknown : verbose PS0265: LOG:  Reference mismatch for 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\mscorlib.dll' [PublicKeyMismatch].
[13:38:25][PostSharp30] unknown : verbose PS0265: LOG:  The assembly 'mscorlib, version=2.0.5.0, culture=neutral, publickeytoken=7cec85d7bea7798e, retargetable=yes' was not found.
[13:38:25][PostSharp30] unknown : verbose PS0265: .
[13:38:25][PostSharp30] unknown error PS0264: Cannot find assembly 'mscorlib, version=2.0.5.0, culture=neutral, publickeytoken=7cec85d7bea7798e'. [Public key mismatch]. Build your project with detailed verbosity to see the assembly loading log.
[13:38:25][PostSharp30] C:\BuildAgent\work\be9df088c843a629\src\packages\PostSharp.5.0.43\build\PostSharp.targets(314, 5): The process C:\ProgramData\PostSharp\5.0.43\bin.Release\postsharp-net40-x86-native.exe exited with code 11.
[13:38:25][Step 4/5] Process exited with code 1

Update

After comparing file (local vs build server) in C:\ProgramData\PostSharp\InstalledFrameworks, I can see that my local machine has these additional frameworks:

  <Framework Identifier=".NETFramework" Version="4.7.1">
    <ReferenceAssemblies>
      <Directory Location="C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.1\" />
    </ReferenceAssemblies>
  </Framework>
  <Framework Identifier=".NETPortable" Version="4.0">
    <ReferenceAssemblies>
      <Directory Location="C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETPortable\v4.0\" />
    </ReferenceAssemblies>
  </Framework>
  <Framework Identifier=".NETPortable" Version="4.5">
    <ReferenceAssemblies>
      <Directory Location="C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETPortable\v4.5\" />
    </ReferenceAssemblies>
  </Framework>
  <Framework Identifier=".NETPortable" Version="4.6">
    <ReferenceAssemblies>
      <Directory Location="C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETPortable\v4.6\" />
    </ReferenceAssemblies>
  </Framework>
  <Framework Identifier=".NETPortable" Version="5.0">
    <ReferenceAssemblies>
      <Directory Location="C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETPortable\v5.0\" />
    </ReferenceAssemblies>
  </Framework>

回答1:


The build server required Microsoft .NET Portable Library Reference Assemblies 4.6:

  1. Download & install Microsoft .NET Portable Library Reference Assemblies 4.6
  2. Extract C:\Program Files (x86)\Microsoft .NET Portable Library Reference Assemblies 4.6\PortableReferenceAssemblies.zip to C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETPortable\

Note: Character casing of the folder ".NETPortable" must be as defined. Use mkdir to create folders starting with a period symbol.




回答2:


Copying C:\ProgramData\PostSharp\BindingMaps from my local machine to the build server worked for me (Postsharp 4.2.19)



来源:https://stackoverflow.com/questions/48188810/postsharp-not-building-on-teamcity-cannot-find-assembly-mscorlib

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!