我想添加和删除文件,当我的MSBuild 15的MSBuild:添加和删除文件到的MSBuild 15发布输出@ BeforeTargets =“PrepareForPublish”
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Folder Include="wwwroot\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0" />
</ItemGroup>
<!-- My target, which is only executed on publication , Which is desirable in my case -->
<Target Name="MyPrepareForPublish" BeforeTargets="PrepareForPublish">
<!-- Delete old files in wwwroot from Content -->
<ItemGroup>
<Content Remove="wwwroot\**"/>
</ItemGroup>
<!-- I Add and removes files to file system in wwwroot here , Exclude="@(Content)" prevents duplicates from outside wwwroot -->
<!-- Adding new files to Content form wwwroot -->
<ItemGroup>
<Content Include="wwwroot\**" Exclude="@(Content)"/>
</ItemGroup>
</Target>
</Project>
发布但当我删除和添加文件,我得到一个错误信息:
(109,5): Error MSB3030: Could not copy the file "C:\buildTest\WebsSrver\wwwroot\main.d158e9e1259986c4bd76.bundle.js" because it was not found.
我的代码删除“main.d158e9e1259986c4bd76.bundle.js”,并创建一个新的与MyPrepareForPublish另一个名字。
这些文件位于wwwroot im my dotnet核心项目中。
那么如何指定发布输出中应包含哪些内容?
在此先感谢!
该目标究竟是什么?你添加/删除“内容”项目?你使用的是2.0.0 SDK吗? (它有一些修复这种情况下) –
你使用2.0.0:是的,我认为是这样的 “C:\ Program Files \ dotnet \ sdk \ 2.0.0 \ Sdks \ Microsoft.NET.Sdk \ build \ Microsoft .NET.Publish.targets“和在proj文件的topp中。该目标究竟是什么? :你的意思是什么? –
我的意思是你的'MyPrepareForPublish'目标用来修改文件和项目 –