---
# System prepended metadata

title: MSBuild ビルド中にメッセージを表示する 2021-11-10
tags: [Message, MSBuild]

---

---
lang: ja-jp
breaks: true
---
# MSBuild ビルド中にメッセージを表示する 2021-11-10

```xml=
<Target Name="NameBefore" BeforeTargets="BeforeBuild">
    <Message Importance="high" Text="----------------- before [$(AssemblySearchPaths)]" />
</Target>

<Target Name="NameAfter" AfterTargets="AfterBuild">
    <Message Importance="high" Text="----------------- after  [$(AssemblySearchPaths)]" />
</Target>
```

```xml=
<Project Sdk="Microsoft.NET.Sdk" InitialTargets="BeforeBuild">
    
  <Target Name="BeforeBuild">
    <Message Importance="High" Text="MSBuildBinPath                 =$(MSBuildBinPath)                " />
    <Message Importance="High" Text="MSBuildExtensionsPath          =$(MSBuildExtensionsPath)         " />
    <Message Importance="High" Text="MSBuildExtensionsPath32        =$(MSBuildExtensionsPath32)       " />
    <Message Importance="High" Text="MSBuildExtensionsPath64        =$(MSBuildExtensionsPath64)       " />
    <Message Importance="High" Text="MSBuildInteractive             =$(MSBuildInteractive)            " />
    <Message Importance="High" Text="MSBuildLastTaskResult          =$(MSBuildLastTaskResult)         " />
    <Message Importance="High" Text="MSBuildNodeCount               =$(MSBuildNodeCount)              " />
    <Message Importance="High" Text="MSBuildProgramFiles32          =$(MSBuildProgramFiles32)         " />
    <Message Importance="High" Text="MSBuildProjectDefaultTargets   =$(MSBuildProjectDefaultTargets)  " />
    <Message Importance="High" Text="MSBuildProjectDirectory        =$(MSBuildProjectDirectory)       " />
    <Message Importance="High" Text="MSBuildProjectDirectoryNoRoot  =$(MSBuildProjectDirectoryNoRoot) " />
    <Message Importance="High" Text="MSBuildProjectExtension        =$(MSBuildProjectExtension)       " />
    <Message Importance="High" Text="MSBuildProjectFile             =$(MSBuildProjectFile)            " />
    <Message Importance="High" Text="MSBuildProjectFullPath         =$(MSBuildProjectFullPath)        " />
    <Message Importance="High" Text="MSBuildProjectName             =$(MSBuildProjectName)            " />
    <Message Importance="High" Text="MSBuildRuntimeType             =$(MSBuildRuntimeType)            " />
    <Message Importance="High" Text="MSBuildStartupDirectory        =$(MSBuildStartupDirectory)       " />
    <Message Importance="High" Text="MSBuildThisFile                =$(MSBuildThisFile)               " />
    <Message Importance="High" Text="MSBuildThisFileDirectory       =$(MSBuildThisFileDirectory)      " />
    <Message Importance="High" Text="MSBuildThisFileDirectoryNoRoot =$(MSBuildThisFileDirectoryNoRoot)" />
    <Message Importance="High" Text="MSBuildThisFileExtension       =$(MSBuildThisFileExtension)      " />
    <Message Importance="High" Text="MSBuildThisFileFullPath        =$(MSBuildThisFileFullPath)       " />
    <Message Importance="High" Text="MSBuildThisFileName            =$(MSBuildThisFileName)           " />
    <Message Importance="High" Text="MSBuildToolsPath               =$(MSBuildToolsPath)              " />
    <Message Importance="High" Text="MSBuildToolsVersion            =$(MSBuildToolsVersion)           " />
    <Message Importance="High" Text="MSBuildVersion                 =$(MSBuildVersion)                " />
    <Message Importance="High" Text="MSBuildAssemblyVersion         =$(MSBuildAssemblyVersion)        " />
    <Message Importance="High" Text="MSBuildFileVersion             =$(MSBuildFileVersion)            " />
    <Message Importance="High" Text="MSBuildSemanticVersion         =$(MSBuildSemanticVersion)        " />
  </Target>
    
</Project>
```

:::info
> 予約済みのプロパティと既知のプロパティ
> https://docs.microsoft.com/ja-jp/visualstudio/msbuild/msbuild-reserved-and-well-known-properties?view=vs-2022#reserved-and-well-known-properties
:::

## `msbuild` での出力内容
```shell=
1>MSBuildBinPath                 =C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Current\Bin\amd64
1>MSBuildExtensionsPath          =C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild
1>MSBuildExtensionsPath32        =C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild
1>MSBuildExtensionsPath64        =C:\Program Files\MSBuild
1>MSBuildInteractive             =
1>MSBuildLastTaskResult          =true
1>MSBuildNodeCount               =36
1>MSBuildProgramFiles32          =C:\Program Files (x86)
1>MSBuildProjectDefaultTargets   =Build
1>MSBuildProjectDirectory        =D:\Tools\XXXXXXXX
1>MSBuildProjectDirectoryNoRoot  =Tools\XXXXXXXX
1>MSBuildProjectExtension        =.csproj
1>MSBuildProjectFile             =XXXXXXXX.csproj
1>MSBuildProjectFullPath         =D:\Tools\XXXXXXXX
1>MSBuildProjectName             =XXXXXXXX
1>MSBuildRuntimeType             =Full
1>MSBuildStartupDirectory        =D:\Tools\XXXXXXXX
1>MSBuildThisFile                =XXXXXXXX.csproj
1>MSBuildThisFileDirectory       =D:\Tools\XXXXXXXX
1>MSBuildThisFileDirectoryNoRoot =Tools\XXXXXXXX
1>MSBuildThisFileExtension       =.csproj
1>MSBuildThisFileFullPath        =D:\Tools\XXXXXXXX.csproj
1>MSBuildThisFileName            =XXXXXXXX
1>MSBuildToolsPath               =C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Current\Bin\amd64
1>MSBuildToolsVersion            =Current
1>MSBuildVersion                 =17.2.1
1>MSBuildAssemblyVersion         =17.0
1>MSBuildFileVersion             =17.2.1.25201
1>MSBuildSemanticVersion         =17.2.1+52cd2da31
```

## `dotnet build`での出力内容

```shell=
  MSBuildBinPath                 =C:\Program Files\dotnet\sdk\7.0.100-preview.4.22252.9
  MSBuildExtensionsPath          =C:\Program Files\dotnet\sdk\7.0.100-preview.4.22252.9\
  MSBuildExtensionsPath32        =C:\Program Files\dotnet\sdk\7.0.100-preview.4.22252.9
  MSBuildExtensionsPath64        =C:\Program Files\dotnet\sdk\7.0.100-preview.4.22252.9
  MSBuildInteractive             =
  MSBuildLastTaskResult          =true
  MSBuildNodeCount               =36
  MSBuildProgramFiles32          =C:\Program Files (x86)
  MSBuildProjectDefaultTargets   =Build
  MSBuildProjectDirectory        =D:\Tools\XXXXXXXX
  MSBuildProjectDirectoryNoRoot  =Tools\XXXXXXXX
  MSBuildProjectExtension        =.csproj
  MSBuildProjectFile             =XXXXXXXX.csproj
  MSBuildProjectFullPath         =D:\Tools\XXXXXXXX.csproj
  MSBuildProjectName             =XXXXXXXX
  MSBuildRuntimeType             =Core
  MSBuildStartupDirectory        =D:\Tools\XXXXXXXX
  MSBuildThisFile                =XXXXXXXX.csproj
  MSBuildThisFileDirectory       =D:\Tools\XXXXXXXX
  MSBuildThisFileDirectoryNoRoot =Tools\XXXXXXXX
  MSBuildThisFileExtension       =.csproj
  MSBuildThisFileFullPath        =D:\Tools\XXXXXXXX.csproj
  MSBuildThisFileName            =XXXXXXXX
  MSBuildToolsPath               =C:\Program Files\dotnet\sdk\7.0.100-preview.4.22252.9
  MSBuildToolsVersion            =Current
  MSBuildVersion                 =17.3.0
  MSBuildAssemblyVersion         =17.0
  MSBuildFileVersion             =17.3.0.22604
  MSBuildSemanticVersion         =17.3.0-preview-22226-04+f15ed2652
```

###### tags: `MSBuild` `Message`
