如何在msbuild中检查文件是否存在且为空
我想检查文件是否存在,并且在msbuild中是否为空。如何执行该操作您可以使用如何在msbuild中检查文件是否存在且为空,msbuild,msbuild-4.0,Msbuild,Msbuild 4.0,我想检查文件是否存在,并且在msbuild中是否为空。如何执行该操作您可以使用Exists和ReadAllText获取文件内容 <Target Name="Build"> <PropertyGroup> <TheFile>C:\Windows\System32\notepad.exe</TheFile> <FileContents Condition="Exists($(TheFile))">$(
Exists
和ReadAllText
获取文件内容
<Target Name="Build">
<PropertyGroup>
<TheFile>C:\Windows\System32\notepad.exe</TheFile>
<FileContents Condition="Exists($(TheFile))">$([System.IO.File]::ReadAllText('C:\\Windows\System32\notepad.exe'))</FileContents>
</PropertyGroup>
<Message Condition="'$(FileContents)' != ''" Text="The file is not empty $(FileContents)" />
</Target>
C:\Windows\System32\notepad.exe
$([System.IO.File]::ReadAllText('C:\\Windows\System32\notepad.exe'))