- csc.exe での実行ファイル作成に限界を感じたのでMSBuild.exeを使うこととした。
ファイル
main.csproj
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Compile Include="*.cs" />
</ItemGroup>
<Target Name="Build">
<Csc Sources="@(Compile)" References="@(Reference)" />
</Target>
</Project>
-
References=
でdll読み込みの指定を渡すことができる。 -
ToolsVersion="4.0"
を書かないと古いC#の記述方法しか使えなかった。 -
ソースファイル
main.cs
using System;
namespace ConsoleApp1 {
class Program {
static void Main(string[] args) {
Console.Write("hello");
}
}
}
- ビルドスクリプト
compile.bat
del main.exe
C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe ^
main.csproj
main.exe
pause
実行ファイルを作る
DLLの追加
main.csproj
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Compile Include="*.cs" />
<Reference Include="QRCodeEncoderDecoderLibrary.dll"/>
</ItemGroup>
<Target Name="Build">
<Csc Sources="@(Compile)" References="@(Reference)" />
</Target>
</Project>