1

多年来,我一直在 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 或者这是所需的行为?

请帮忙谢谢!

4

2 回答 2

2

我想出了我自己的问题。

首先,我的 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 扩展名之外的任何内容。

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

于 2009-10-02T00:13:00.377 回答
1

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

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

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

于 2009-10-01T08:36:39.247 回答