Mik*_*scu 2 .net c# compiler-construction cmd .net-2.0
我正在尝试创建一个脚本来从命令行编译Windows Forms C#2.0项目(我知道,我知道......我重新发明轮子......但是如果有人知道答案,我会很感激它).
该项目是一个标准的Windows窗体项目,它有一些资源并引用了几个外部程序集.这是一个文件列表:
Program.cs // no need to expand on this on :)
frmMain.cs // this is a typical C# windows forms file
frmMain.designer.cs // .. and the designer code
frmMain.resx // .. and the resource file
MyClasses.cs // this contains a couple classes
Properties\AssemblyInfo.cs // the Properties folder -- again pretty standard
Properties\Resources.Designer.cs
Properties\Resources.resz
Properties\Settings.Designer.cs
Properties\Settings.settings
References\AnAssembly.dll // an assmebly that I reference from this application
到目前为止,我已经确定了以下需要的程序/工具:
csc.exe // the C# compiler
al.exe // the assembly linker
resgen.exe // the resource compiler
到目前为止这是我的脚本:
@echo off
set OUT=Out
set AL=C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\al.exe
set RESGEN="C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin\resgen.exe"
set COMPILER=C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\csc.exe
echo.
echo Compiler: %COMPILER%
echo.
if "%1"=="/help" goto help
:start
echo Starting...
set REFERENCES=.\References\AReferencedll
set SRCFILES=Program.cs frmMain.cs frmMain.designer.cs MyClasses.cs Properties\AssemblyInfo.cs Properties\Resources.Designer.cs Properties\Settings.Designer.cs
del /Q %OUT%\*
%RESGEN% /compile frmMain.resx,%OUT%\frmMain.resources
cd Properties
%RESGEN% /compile Resources.resx,..\%OUT%\Resources.resources
cd ..
%COMPILER% /target:module /out:%OUT%\app.module %SRCFILES% /reference:%REFERENCES%
%AL% %OUT%\app.module /embed:%OUT%\frmMain.resources /target:winexe /out:%OUT%\app.exe /main:App.Program.Main
goto done
:error
echo Ooooops!
:done
echo Done!!
最后,无论我如何旋转它,我都会从链接器中获得不同的错误,或者最终的可执行文件将无法运行 - 它会崩溃.
请帮忙(MSDN没帮太多..)!
我喜欢欺骗这些事情.获取一个工作项目并在其上运行以下命令
msbuild Project.csproj /t:rebuild /clp:ShowCommandLine
Run Code Online (Sandbox Code Playgroud)
它的输出将显示msbuild用于编译项目的命令,然后您可以根据需要进行修改.
| 归档时间: |
|
| 查看次数: |
3780 次 |
| 最近记录: |