【问题标题】:Adding a package causes project to always run in debug mode添加包会导致项目始终在调试模式下运行
【发布时间】:2018-12-26 09:35:33
【问题描述】:

当我构建并运行我的项目时,下面的代码

Console.WriteLine("I am running in debug {0}", StaticConfiguration.IsRunningDebug);

debug 模式下产生 true,在 release 模式下产生 false 模式,正如预期的那样。然后我使用 nuget 添加一个包,nuget 服务器是我们本地的 nuget 服务器,它是我们拥有和发布的库。

当我再次运行上述代码时,我在 debug 模式下得到 truetrue 也处于发布模式。

//Get all non-nancy assemblies, and select the custom attributes
var assembliesInDebug
    = AppDomainAssemblyTypeScanner.TypesOf<INancyModule>(ScanMode.ExcludeNancy)
                                  .Select(x => x.Assembly.GetCustomAttributes(typeof(DebuggableAttribute), true))
                                  .Where(x => x.Length != 0);

//if there are any, then return the IsJITTrackingEnabled
//else if the collection is empty it returns false
return assembliesInDebug.Any(d => ((DebuggableAttribute)d[0]).IsJITTrackingEnabled

);

当我查看构建服务器时,看起来好像这些库是在发布模式下构建的。有什么想法可以去哪里看?

更新:

我通过在 Scott Hanselman 网站上找到的代码运行程序集,以检测它们是在调试模式还是发布模式下构建的。出于某种原因,下载的两个 DLL 都是在 debug 模式下构建的。尽管构建服务器上的调用非常明确地说明了发布模式。

所以我现在假设,如果任何 DLL 是在调试模式下构建的,那么整个构建都是因为调试模式

【问题讨论】:

  • 即使在发布模式下构建,该值是否仍然为真?你能解释一下为什么你使用这个代码,而不是#if DEBUG return true;吗?
  • 如果您指的是程序集的扫描,则来自 Nancy 源代码。其他一些代码依赖于该结果

标签: c# visual-studio nuget nancy


【解决方案1】:

添加包会导致项目始终在调试模式下运行

这似乎是 nuget 包 nancy 的问题。

Nancy (2.0.0-clinteastwood) is a Debug build on net452

由于不是正式发布版本,我们可能需要等待正式版本修复此问题,您可以关注您的cmets并查看此问题的反馈。

希望这会有所帮助。

【讨论】:

    猜你喜欢
    • 2015-11-25
    • 1970-01-01
    • 2018-07-26
    • 1970-01-01
    • 2022-09-29
    • 1970-01-01
    • 2019-07-04
    • 1970-01-01
    • 2015-11-06
    相关资源
    最近更新 更多