私は次のことをしています:
- デフォルトのクラス ファイル プロジェクトを作成しました
- csproj ファイルを編集して Pre および Post BuildEvents を含めました
- デフォルトでコメントアウトされた BeforeBuild および AfterBuild ターゲットのコメントを解除します
BeforeBuild および AfterBuild ターゲットは、Visual Studio 内ではフォームと呼ばれませんが、msbuild コマンド ラインから呼び出されます。なぜですか?
私は PostBuildEvent ではなく msbuild ターゲットを使用したいと考えています。
乾杯、
アダム
出力のパスの一部を短縮したため、一貫性がない場合はそれが理由です
ClassLibrary1.csproj の変更
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="BeforeBuild">
<Message Text="### BeforeBuild ###" />
</Target>
<Target Name="AfterBuild">
<Message Text="### AfterBuild ###" />
</Target>
<PropertyGroup>
<PreBuildEvent>echo PRE_BUILD</PreBuildEvent>
</PropertyGroup>
<PropertyGroup>
<PostBuildEvent>echo POST_BUILD</PostBuildEvent>
</PropertyGroup>
VS 2010 からの私のビルド出力は
------ Rebuild All started: Project: ClassLibrary1, Configuration: Debug Any CPU ------
PRE_BUILD
ClassLibrary1 -> c:\ClassLibrary1\bin\Debug\ClassLibrary1.dll
POST_BUILD
========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========
コマンドラインから
#>msbuild ClassLibrary1.sln
Microsoft (R) Build Engine Version 4.0.30319.1
[Microsoft .NET Framework, Version 4.0.30319.239]
Copyright (C) Microsoft Corporation 2007. All rights reserved.
Build started 09/05/2012 13:27:42.
Project "c:.sln" on node 1 (default targets).
ValidateSolutionConfiguration:
Building solution configuration "Debug|Any CPU".
Project "c:.sln" (1) is building "c:\ClassLibrary1.csproj" (2) on node 1 (default targets).
BeforeBuild:
### BeforeBuild ###
PreBuildEvent:
echo PRE_BUILD
PRE_BUILD
GenerateTargetFrameworkMonikerAttribute:
Skipping target "GenerateTargetFrameworkMonikerAttribute" because all output files are up-to-date with respect to the input files.
CoreCompile:
Skipping target "CoreCompile" because all output files are up-to-date with respect to the input files.
CopyFilesToOutputDirectory:
ClassLibrary1 -> c:\bin\Debug\ClassLibrary1.dll
PostBuildEvent:
echo POST_BUILD
POST_BUILD
AfterBuild:
### AfterBuild ###
Done Building Project "c:\ClassLibrary1.csproj" (default targets).
Done Building Project "c:.sln" (default targets).
Build succeeded.
0 Warning(s)
0 Error(s)
Time Elapsed 00:00:00.18