我有一个用于自动安装 ClickOnce 的 msbuild 脚本。尝试将版本信息添加到发布目录时,尝试使用该版本构建路径字符串时出现错误。
<Target Name="GetVersion">
<Message Text="Getting version info..."/>
<GetAssemblyIdentity AssemblyFiles="@(GetVersionAssembly)">
<Output TaskParameter="Assemblies"
ItemName="GetVersionAssemblyInfo"/>
</GetAssemblyIdentity>
<Message Text="%(GetVersionAssemblyInfo.Version)..."/>
</Target>
<Target Name="CopyFilesToVirtualRoot" DependsOnTargets="PrepareClickOnceDeployment;DeleteVirtualRootFiles;GetVersion">
<Message Text="Copying files to $(ClickOnceVirtualRootDir)..."/>
<Copy SourceFiles="@(ClickOnceInstallationFiles)"
DestinationFiles="@(ClickOnceInstallationFiles->'$(ClickOnceVirtualRootDir)\%(Filename)%(Extension)')"/>
<Copy SourceFiles="@(AppManifestContents)"
DestinationFiles="@(AppManifestContents->'$(ClickOnceVirtualRootDir)\Application Files\Version_%(GetVersionAssemblyInfo.Version)\%(RecursiveDir)%(Filename)%(Extension).deploy')"/>
</Target>
运行时出现以下错误
error MSB4043: The item metadata reference "%(GetVersionAssemblyInfo.Version)" is invalid
because it is qualified with an item name. Item metadata referenced in transforms do not
need to be qualified, because the item name is automatically deduced from the items being
transformed. Change "%(GetVersionAssemblyInfo.Version)" to "%(Version)".
如果我将其更改为 %(Version) 我得到的只是一个空白。