我当前的项目结构是
solution dir
-- clientDir
-- serverDir
发布服务器项目时,我试图发布clientdir,以下是我对csproj
文件所做的更改
<PropertyGroup>
<SpaRoot>$(SolutionDir)ClientDir\</SpaRoot>
</PropertyGroup>
然后添加一个目标
<Target Name="PublishRunWebpack" AfterTargets="ComputeFilesToPublish">
<ItemGroup>
<DistFiles Include="$(SpaRoot)dist\myapp\**" />
<ResolvedFileToPublish Include="@(DistFiles->'%(FullPath)')" Exclude="@(ResolvedFileToPublish)">
<RelativePath>%(DistFiles.Identity)</RelativePath>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</ResolvedFileToPublish>
</ItemGroup>
</Target>
但是我得到了错误
无法将文件“ C:... \ ClientDir \ dist \ myapp \ scripts.js.map”复制到 “ C:\ PublishDir \ PubTmp \ Out \ C:... \ ClientDir \ dist \ myapp \ scripts.js.map”。 不支持给定路径的格式。 ICollect.Public.WebApi
它将源文件的完整路径附加到发布路径...
答案 0 :(得分:0)
通过此链接,我解决了问题
https://docs.microsoft.com/en-us/visualstudio/msbuild/msbuild-well-known-item-metadata?view=vs-2019
将相对路径更改为
<RelativePath>%(DistFiles.RecursiveDir)%(DistFiles.Filename)%(Extension)</RelativePath>