簡體   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