繁体   English   中英

aspnet_compiler不会编译放置在Web应用程序目录下的C#代码

[英]aspnet_compiler won’t compile c# code placed under web application directory

我一直在Visual Studio中使用鼠标右键单击来发布网站已有很长时间了,除非手动工作太多,否则一切都很好。 最近,我更改为使用构建脚本来调用aspnet_compiler来发布ASP.NET Web应用程序。 在我的构建脚本中,我将执行以下操作:

sh "#{aspnet_compiler} -p ../src/webapp -v targetDir ./publish –u"

我的项目目录结构如下所示:

/build/rakefile.rb
/build/publish/ --published site goes here
/src/website/bll/ --business logic goes here
/src/website/ --aspx pages
/src/website/code/ --some c# code

调用aspnet-compiler时,除/ src / website / code /下的c#代码不会被编译外,其他所有东西都可以正常工作。 在我看来,aspnet-compiler 在bll目录下编译了c#代码,然后将/ src / website /下的所有内容都复制到了发布目录(包括/ src / website / code /)中。 我不知道我是否使用了不正确的开关调用aspnet-compiler,或者这是期望的行为?

请帮忙谢谢!

我想出了自己的问题。

首先,我的rake构建脚本最终如下所示:

sh "#{aspnet_compiler} -f -fixednames -u -p ../src/website -v / ./publish"

其次,在Visual Studio中鼠标右键单击“发布”的输出行为不同于调用aspnet_compiler。

右键单击发布将:

  • 直接复制Global.asax
  • bin目录下仅生成.dll.pdb文件(如果不需要调试,可以删除.pdb文件)文件

调用aspnet_compiler时的位置:

  • 会将Global.asax编译为bin目录下的App_global.asax.compiledApp_global.asax.dll
  • 还将生成PrecompiledApp.config (这是因为我指定了aspx页面应该是可更新的)

发布任务之后有一个清理任务,该任务基本上删除了bin下.dll扩展名以外的任何内容。

无论如何,我现在学到了一些新东西。

在构建计算机上使用aspnet_compiler时,我遇到了类似的问题(我使用了MSBuild)。 对我来说,解决方案是在调用aspnet_compiler之前构建解决方案。 在MSBuild中,它看起来像:

<MSBuild Projects="$(PhysicalPath)\solutionName.sln" Properties="Configuration=Debug"/>

您也可以使用devenv solutionName.sln / build(如果不使用MSBuild)。

暂无
暂无

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

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