Quantcast
Channel: C#タグが付けられた新着記事 - Qiita
Viewing all articles
Browse latest Browse all 9703

ビルド日時のリソース埋め込み

$
0
0

手段

参考:Displaying the build date
https://stackoverflow.com/questions/1600962/displaying-the-build-date/22163375

PEヘッダから取得する方法があるらしい。
しかし、細かい情報を入れたいこともありビルド前イベントを使って自前のリソースを追加する。

mkdir  "$(ProjectDir)\Resources\"
echo %date% %time% > "$(ProjectDir)\Resources\BuildDate.txt"

これだけだと、同名フォルダが存在する場合にエラーになる。

参考:
http://biglibox.hatenablog.jp/entry/2016/09/27/125444

mkdir  "$(ProjectDir)\Resources\" > NUL 2>&1
if ERRORLEVEL 1 cmd /c exit 0
echo %date% %time% > "$(ProjectDir)\Resources\BuildDate.txt"

と書いたが結局、素直にアセンブリのバージョンから求めた方がいいと思いました。

System.Reflection.Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly();
System.Version version = asassembly.GetName().Version;

.NET core 3.0ではAssenblyInfo.csが無くなっていて、
プロジェクトのプロパティに組み込まれているのだが、
ワイルドカードが入力できなくて、BuildNumberのAuto increase設定に困っている。


Viewing all articles
Browse latest Browse all 9703

Trending Articles