「[[マイクロソフト系技術情報 Wiki>http://techinfoofmicrosofttech.osscons.jp/]]」は、「[[Open棟梁Project>https://github.com/OpenTouryoProject/]]」,「[[OSSコンソーシアム .NET開発基盤部会>https://www.osscons.jp/dotNetDevelopmentInfrastructure/]]」によって運営されています。

-[[戻る>ビルドスクリプト]]

* 目次 [#w1af5e5c]
#contents

*概要 [#ke090c94]
-nmakeツールの機能的な後継
-Visual StudioプロジェクトをIDE無しでビルドできる。

-[[MSBuild]]をコマンドラインで呼び出してビルドできる。
--MSBuild コマンド ライン リファレンス~
http://msdn.microsoft.com/ja-jp/library/ms164311.aspx
--
 MSBuild /build release solution.sln

-[[タスク>#c6f0f3fe]]を利用すると種々の作業を自動化できる。

*タスク [#c6f0f3fe]
-タスクを利用すると種々の作業を自動化できる。
-プロジェクトファイルの<Target>要素にタスクを記載する。

**標準タスク [#zf511266]
-MSBuild タスク~
https://msdn.microsoft.com/ja-jp/library/ms171466.aspx
-MSBuild タスク リファレンス~
https://msdn.microsoft.com/ja-jp/library/7z253716.aspx

**Communityタスク [#n3b89f12]
-loresoft/msbuildtasks:~
The MSBuild Community Tasks Project is an open source project for MSBuild tasks.~
https://github.com/loresoft/msbuildtasks

*メモ [#yc9525c2]
**MSbuild 14.0 [#p0bbfd82]
-Visual Stadio 2015ではMSbuild 14.0がインストール&利用される。
--C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe
--C:\Program Files (x86)\MSBuild\14.0

-「NuGet auto package restore does not work with MSBuild]が発生した。~
--.net - NuGet auto package restore does not work with MSBuild - Stack Overflow~
https://stackoverflow.com/questions/22300375/nuget-auto-package-restore-does-not-work-with-msbuild

**MSbuild 15.0 [#j48afe67]
-Visual Stadio 2017ではMSbuild 15.0がインストール&利用される。
--C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe
--C:\Program Files (x86)\MSBuild\15.0

-[[NuGet]]のバージョンは、MSbuild 14.0では3.5までとなっており、MSbuild 15.0では4.0以上が必要。
--以下の文字列を使用して検索すると情報が見つかる。
 Failed to load msbuild Toolset Could not load file or assembly 'Microsoft.Build, Version=14.0.0.0

*トラブルシュート [#qf9870d5]
devenvでのビルドと比べ、チラホラと、エラーが起きる。

**ビルド時 [#k9e791f6]

***[[ビルド時に「error MSB4019 ... `MSBuild\...\Microsoft.WebApplication.targets` was not found...」が発生]] [#x8dd92dc]
>最近、[[Visual Studio 2017>Visual Studio#ob9cfcd1]]のMSBuild(v15.0)に標準同梱されていなくて、~
Webアプリケーションのビルドに失敗するケースが増えているようです。

***[[ビルド時に「due to its being in the Internet or Restricted zone or having the mark of the web on the file.」が発生]] [#z109092f]
>GitHubから「Download ZIP」して、Explorerで解凍した場合など、この問題が起きます。

***[[ビルド時に「error CS1519 Unexpected symbol 'xxxxx' in class, struct, or interface member declaration.」が発生]] [#nfbe77c8]
>[[C#>C Sharp]]のバージョン(コンパイラ)の問題らしいです。

***[[PackageReferenceに切り替え後のビルドで「error CS0246 The type or namespace name ...」が発生]] [#ne8bd624]

**NuGet使用時 [#e5047399]

***[[Nuget使用時に「error MSB3086 Task could not find AL.exe」が発生]] [#u0d7328f]
>MSBuildでのビルドに必要なSDKがインストールされていなくてエラーになるというケース。

***[[Nuget使用時に「warning MSB3247 Found conflicts between different versions of the same dependent assembly.」が発生]] [#q301b5b3]

-恐らく、[[NuGet]]導入により多くの人が遭遇している問題。

-バインディング リダイレクトによって対応可能。

***[[Nuget使用時に「warning NU1701 Package 'xxxxx' was restored using 'yyyyy' instead of the project target framework 'zzzzz'...」が発生>NuGet を使用したパッケージ管理#hfdecb5a]] [#t9272c99]

-netからnetcoreappのパッケージを参照した場合などに発生する。

-また、netとnetstandardが混在している場合、net側でnetstandardを~
サポートしていないアセンブリを使用しているだけで発生する。

-[[NuGet]]と[[Visual Studio]]の問題なので将来的に解決するかもしれません。

*参考 [#ha2beebc]
-MSBuild - Wikipedia~
https://ja.wikipedia.org/wiki/MSBuild
-MSBuildを活用して開発時の作業を自動化する:CodeZine(コードジン)~
http://codezine.jp/article/detail/674

----
Tags: [[:.NET開発]], [[:テスト]], [[:デバッグ]], [[:デプロイ]], [[:ツール類]], [[:CI]]


トップ   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS