Sim*_*een 13 .net teamcity self-hosting owin
当Teamcity运行启动自托管Web应用程序的集成测试时,测试将失败并显示错误:
System.MissingMemberException: The server factory could not be located for the given input: Microsoft.Owin.Host.HttpListener
Run Code Online (Sandbox Code Playgroud)
抛出此错误的代码是:
var webApp = WebApp.Start<Startup>("http://*:52203/")
Run Code Online (Sandbox Code Playgroud)
使用Visual Studio(使用Resharper测试运行器)执行测试时运行正常.Teamcity配置为使用JetBrains.BuildServer.NUnitLauncher.exe可执行文件来运行测试.
我看到很多关于这个错误的帖子与Microsoft.Owin.Host.HttpListener.dllbin 有关,因为bin\debug或bin\release文件夹中没有.我可以确认此文件(以及随附的.xml文件)都存在于TeamCity buildAgent使用的bin\release文件夹中.没有bin\debug文件夹.
Ada*_*ess 16
我在我的Powershell脚本中遇到了这个问题,它迭代我们所有的解决方案并使用MSBuild构建它们,然后在所有测试项目上调用MSTest.此脚本用于在提交到TFS之前在本地构建和测试所有解决方案.在VS中运行测试时不会出现此问题.我相信这与这个问题有关.
在测试初始化中调用WebApp.Start("http://*:52203 /")之前放置以下内容.
// This uber silly code is needed to ensure the Owin HttpListener assembly
// is properly copied to the output directory by using it, utterly redonkulous.
var uberSillyNecessity = typeof(OwinHttpListener);
if (uberSillyNecessity != null) { }
Run Code Online (Sandbox Code Playgroud)
Kev*_*vin 12
我遇到了同样的问题:在本地运行良好,但在TeamCity代理上失败.
我的测试项目通过nuget引用了Microsoft.Owin.Host.HttpListener
对我有用的是在启动Web应用程序之前显式加载Microsoft.Owin.Host.HttpListener dll.
// load assembly
AppDomain.CurrentDomain.Load(typeof(Microsoft.Owin.Host.HttpListener.OwinHttpListener).Assembly.GetName());
Run Code Online (Sandbox Code Playgroud)