如何在没有 Visual Studio 的情况下打包 ASP.NET Web 应用程序?

发布于 2024-09-24 06:28:35 字数 4066 浏览 3 评论 0原文

我有一个测试服务器,我也想将其用于 CI。

计划是设置 Hudson 监听 git 存储库,在新提交时获取更改,构建解决方案,运行测试(获取输出),设置测试环境 Web 应用程序(如果一切看起来都是绿色的)并且 显示 Chuck Norris

我正在努力解决第一部分(git 端口已关闭 atm,但这不是这个问题的重点)和最后一部分。

应用程序本身是使用 .Net 4.0、Asp.Net Mvc 2 RTM 和一堆第三方工具构建的。

起初 - 根本无法构建任何东西 - 下载了.Net 4.0 sdk 套件,它有所帮助。然后 - 无法构建 Web 项目 - 只是将 C:\Program Files\MSBuild\Microsoft\VisualStudio\v10.0\ 文件夹内容从我的开发工作站复制到服务器。然后我必须安装 asp.net mvc2 rtm 本身,解决方案终于成功构建。

问题出在 albacore 构建脚本的最后一步,我取自 这里

这是输出:

C:\temp\buildtest>rake -f build.rb (在 C:/temp/buildtest 中) Microsoft(R)构建引擎版本4.0.30319.1 [微软.NET框架,版本4.0.30319.1] 版权所有 (C) Microsoft Corporation 2007。保留所有权利。

域名 -> C:\temp\buildtest\src\Domain\bin\Release\Domain.dll
基础设施 -> C:\temp\buildtest\src\Infrastruct\bin\Release\Infra.dll
坚持-> C:\temp\buildtest\src\Persistence\bin\Release\Persistence.dll
应用程序-> C:\temp\buildtest\src\App\bin\Release\App.dll
网页-> C:\temp\buildtest\src\Web\bin\Release\Web.dll
用户界面-> C:\temp\buildtest\src\UI\bin\UI.dll
单位-> C:\temp\buildtest\src\UnitTests\bin\Release\Unit.dll
整合-> C:\temp\buildtest\src\Integration\bin\Release\Integration.dll
xUnit.net 控制台测试运行程序(32 位 .NET 4.0.30319.1)
版权所有 (C) 2007-10 Microsoft Corporation。

xunit.dll:版本 1.6.1.1521
测试程序集:C:\temp\buildtest\src\UnitTests\bin\Release\src\UnitTests\bin\Release\Unit.dll

总共 84 个,0 个失败,0 个跳过,耗时 9.560 秒
xUnit.net 控制台测试运行程序(32 位 .NET 4.0.30319.1)
版权所有 (C) 2007-10 Microsoft Corporation。

xunit.dll:版本 1.6.1.1521
测试程序集:C:\temp\buildtest\src\Integration\bin\Release\src\Integration\bin \Release\Integration.dll

总共 27 个,0 个失败,0 个跳过,耗时 34.472 秒

未处理的异常:System.TypeInitializationException:类型初始值设定项 fo r“Microsoft.Build.CommandLine.MSBuildApp”引发异常。 --->系统.IO.Fi leNotFoundException:无法加载文件或程序集“Microsoft.Build.Engine,Ve” rsion=3.5.0.0、Culture=neutral、PublicKeyToken=b03f5f7f11d50a3a' 或其 d 之一 附属物。系统找不到指定的文件。 文件名:'Microsoft.Build.Engine,版本=3.5.0.0,文化=中性,PublicKeyT 奥肯=b03f5f7f11d50a3a' 在 Microsoft.Build.CommandLine.MSBuildApp..cctor()

警告:程序集绑定日志记录已关闭。 要启用程序集绑定失败日志记录,请设置注册表值 [HKLM\Software\M icrosoft\Fusion!EnableLog] (DWORD) 为 1。 注意:程序集绑定失败会带来一些性能损失 乞讨。 要关闭此功能,请删除注册表值 [HKLM\Software\Microsoft\Fus ion!EnableLog]。

--- 内部异常堆栈跟踪结束 --- 在 Microsoft.Build.CommandLine.MSBuildApp.Main() F,[2010-09-18T00:35:07.728632 #2072] 致命 - :MSBuild 失败。请参阅构建日志 F 或详细信息 耙子中止! MSBuild 失败。详细信息请参见构建日志 C:/Ruby191/lib/ruby/gems/1.9.1/gems/albacore-0.1.5/lib/albacore/msbuild.rb:41:in `构建解决方案' (通过使用 --trace 运行任务查看完整跟踪)

C:\temp\buildtest>

这就是我的长鳍金枪鱼脚本的样子:

require 'rubygems'
require 'albacore'
task :default => :publish

desc "Builds Interreg solution"
msbuild :build do |m|
  m.path_to_command = File.join(ENV["windir"], 
    "Microsoft.NET", "Framework", "v4.0.30319", "MSBuild.exe")
  m.properties :configuration => :Release
  m.targets :Clean, :Build
  m.solution = "Interreg.sln"
  m.verbosity = "minimal"
end

desc "Runs some tests"
xunit :tests => :build do |x|
  x.path_to_command = "lib/xunitnet/xunit.console.clr4.x86.exe"
  x.assemblies "src/UnitTests/bin/Release/Unit.dll",
    "src/Integration/bin/Release/Integration.dll"
  x.html_output = "doc"
end

desc "Publishes web application"
msbuild :publish=>:tests do |m|
  m.properties={:configuration=>:Release}
  m.targets [:ResolveReferences, :_CopyWebApplication]
  m.properties={
   :webprojectoutputdire=>"c:/temp/outputdir/",
   :outdir=>"c:/temp/outputdir/bin/"
  }
  m.solution="src/UI/UI.csproj"
end

那么...缺少什么?如何让它发挥作用?

如何在没有 Visual Studio 的情况下打包 ASP.NET Web 应用程序?

I got test server which I would like to use for CI too.

Plan is to setup Hudson that listens to git repository, on new commit fetches changes, builds solution, runs tests (picks up output), setups test environment web application if everything looks green and shows Chuck Norris.

I'm struggling with first part (git ports are closed atm but that's not the point of this question) and last part.

Application itself is built using .Net 4.0, Asp.Net Mvc 2 RTM and bunch of 3rd party tools.

At first - couldn't build anything at all - downloaded .Net 4.0 sdk kit and it helped. Then - could not build web project - just copied C:\Program Files\MSBuild\Microsoft\VisualStudio\v10.0\ folder contents from my dev workstation to server. Then I had to install asp.net mvc2 rtm itself and solution finally was building successfully.

Problem is with last step in albacore build script which i took from here.

Here's output:

C:\temp\buildtest>rake -f build.rb
(in C:/temp/buildtest)
Microsoft (R) Build Engine Version 4.0.30319.1
[Microsoft .NET Framework, Version 4.0.30319.1]
Copyright (C) Microsoft Corporation 2007. All rights reserved.

Domain -> C:\temp\buildtest\src\Domain\bin\Release\Domain.dll
Infra -> C:\temp\buildtest\src\Infrastructure\bin\Release\Infra.dll
Persistence -> C:\temp\buildtest\src\Persistence\bin\Release\Persistence.dll
App -> C:\temp\buildtest\src\App\bin\Release\App.dll
Web -> C:\temp\buildtest\src\Web\bin\Release\Web.dll
UI -> C:\temp\buildtest\src\UI\bin\UI.dll
Unit -> C:\temp\buildtest\src\UnitTests\bin\Release\Unit.dll
Integration -> C:\temp\buildtest\src\Integration\bin\Release\Integration.dll
xUnit.net console test runner (32-bit .NET 4.0.30319.1)
Copyright (C) 2007-10 Microsoft Corporation.

xunit.dll: Version 1.6.1.1521
Test assembly: C:\temp\buildtest\src\UnitTests\bin\Release\src\UnitTests\bin\Release\Unit.dll

84 total, 0 failed, 0 skipped, took 9.560 seconds
xUnit.net console test runner (32-bit .NET 4.0.30319.1)
Copyright (C) 2007-10 Microsoft Corporation.

xunit.dll: Version 1.6.1.1521
Test assembly: C:\temp\buildtest\src\Integration\bin\Release\src\Integration\bin
\Release\Integration.dll

27 total, 0 failed, 0 skipped, took 34.472 seconds

Unhandled Exception: System.TypeInitializationException: The type initializer fo
r 'Microsoft.Build.CommandLine.MSBuildApp' threw an exception. ---> System.IO.Fi
leNotFoundException: Could not load file or assembly 'Microsoft.Build.Engine, Ve
rsion=3.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its d
ependencies. The system cannot find the file specified.
File name: 'Microsoft.Build.Engine, Version=3.5.0.0, Culture=neutral, PublicKeyT
oken=b03f5f7f11d50a3a'
at Microsoft.Build.CommandLine.MSBuildApp..cctor()

WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\M
icrosoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure lo
gging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fus
ion!EnableLog].

--- End of inner exception stack trace ---
at Microsoft.Build.CommandLine.MSBuildApp.Main()
F, [2010-09-18T00:35:07.728632 #2072] FATAL -- : MSBuild Failed. See Build Log F
or Detail
rake aborted!
MSBuild Failed. See Build Log For Detail
C:/Ruby191/lib/ruby/gems/1.9.1/gems/albacore-0.1.5/lib/albacore/msbuild.rb:41:in
`build_solution'
(See full trace by running task with --trace)

C:\temp\buildtest>

This is how my albacore script looks like:

require 'rubygems'
require 'albacore'
task :default => :publish

desc "Builds Interreg solution"
msbuild :build do |m|
  m.path_to_command = File.join(ENV["windir"], 
    "Microsoft.NET", "Framework", "v4.0.30319", "MSBuild.exe")
  m.properties :configuration => :Release
  m.targets :Clean, :Build
  m.solution = "Interreg.sln"
  m.verbosity = "minimal"
end

desc "Runs some tests"
xunit :tests => :build do |x|
  x.path_to_command = "lib/xunitnet/xunit.console.clr4.x86.exe"
  x.assemblies "src/UnitTests/bin/Release/Unit.dll",
    "src/Integration/bin/Release/Integration.dll"
  x.html_output = "doc"
end

desc "Publishes web application"
msbuild :publish=>:tests do |m|
  m.properties={:configuration=>:Release}
  m.targets [:ResolveReferences, :_CopyWebApplication]
  m.properties={
   :webprojectoutputdire=>"c:/temp/outputdir/",
   :outdir=>"c:/temp/outputdir/bin/"
  }
  m.solution="src/UI/UI.csproj"
end

So... What is missing? How to make it work?

How to package asp.net web application w/o visual studio?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

把梦留给海 2024-10-01 06:28:35

在 CI 服务器上安装 Windows 7 SDK,其中包括在 CI 服务器上构建 .NET 4 应用程序所需的一切。这将处理您在 GAC 中所需的所有依赖项,并防止您必须从开发工作站手动复制一堆文件。

http://msdn.microsoft.com/en-us/windows/bb980924。 ASPX

Install the Windows 7 SDK on your CI server, which includes everything you need to build .NET 4 applications on your CI server. This will take care of all the dependencies that you need in the GAC, and prevent you from having to manually copy a bunch of files from your development workstation.

http://msdn.microsoft.com/en-us/windows/bb980924.aspx

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文