我面临的问题是我的目标“CopyBuildFiles”没有复制,因为我认为它无法找到构建文件夹。构建文件夹在属性 $(BuildFolder) 中定义,此文件夹名称是根据 date.time 创建的,并且是在“CopyBuildFiles”之前运行的先前目标之一中创建的。
如果我硬编码 @(SrcFiles) 的路径,而不是从 $(BuildFolder) 派生它,它就可以工作。
有什么想法,这里发生了什么,如何解决?
非常感谢。
<PropertyGroup>
<year>$([System.DateTime]::Now.ToString("yy"))</year>
<month>$([System.DateTime]::Now.ToString("MM"))</month>
<day>$([System.DateTime]::Now.ToString("dd"))</day>
<time>$([System.DateTime]::Now.ToString("HHmm"))</time>
<AssemblyFileVersionAttribute>[$(year).$(month).$(day).$(time))] </AssemblyFileVersionAttribute>
<BuildFolder>c:\website.builds\$(AssemblyFileVersionAttribute)\</BuildFolder>
<IISFolder>c:\website.publish\</IISFolder>
<LogDirectory>C:\website.builds.logs</LogDirectory>
<LogFile>C:\website.builds.logs\Buildlog_$(AssemblyFileVersionAttribute).txt</LogFile>
</PropertyGroup>
<Target Name="PreBuild">
<MakeDir Directories="$(LogDirectory)" />
<RemoveDir Directories="$(IISFolder)"></RemoveDir>
<MakeDir Directories="$(BuildFolder)" />
<MakeDir Directories="$(IISFolder)" />
</Target>
<Target Name="Compile">
<MSBuild Projects="$(MSBuildStartupDirectory)\websitev2.sln" Properties="OutDir=$(BuildFolder)\" />
</Target>
<ItemGroup>
<SrcFiles Include="$(BuildFolder)_PublishedWebsites\**\*.*"/>
</ItemGroup>
<Target Name="CopyBuildFiles"
Inputs="@(SrcFiles)"
Outputs=
"@(SrcFiles->'$(IISFolder)%(RecursiveDir)%(Filename)%(Extension)')">
<Copy SourceFiles="@(SrcFiles)"
DestinationFiles="@(SrcFiles->'$(IISFolder)%(RecursiveDir)%(Filename)%(Extension)')"
/>
</Target>
<Target Name="Deploy">
<CallTarget Targets="PreBuild" />
<CallTarget Targets="Compile" />
<CallTarget Targets="CopyBuildFiles" />
</Target>