admin管理员组文章数量:1201410
I want to delete appsettings.json from the publish folder after publishing the web application. I've added a bat file to do the job and call it on AfterTargets="Publish". My bat file gets executed fine, but it seems the published files are copied in the folder after the script has been called. How can I achieve my goal (without using time delay in the bat)?
The publish profile looks like this:
<Project>
<PropertyGroup>
<DeleteExistingFiles>true</DeleteExistingFiles>
<ExcludeApp_Data>false</ExcludeApp_Data>
<LaunchSiteAfterPublish>true</LaunchSiteAfterPublish>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<PublishProvider>FileSystem</PublishProvider>
<PublishUrl>C:\Publish\MyWebApp</PublishUrl>
<WebPublishMethod>FileSystem</WebPublishMethod>
<_TargetId>Folder</_TargetId>
<SiteUrlToLaunchAfterPublish />
<TargetFramework>net9.0</TargetFramework>
<ProjectGuid>dd151040-6c68-4080-986d-fc920e06a562</ProjectGuid>
<SelfContained>false</SelfContained>
</PropertyGroup>
</Project>
I've set the target in MyWebApp.csproj:
<Target Name="AfterPublishDelSet" AfterTargets="Publish">
<Exec Command="dset.bat $(PublishUrl)" />
</Target>
dset.bat changes the directory and tries to delete appsettings.json:
cd %1
IF EXIST appsettings.json (
del appsettings.json
) ELSE (
ECHO "appsettings.json not found"
)
And the output seems to indicate that the files are copied in the publish dir from PubTmp\Out after the script is called:
MyWebApp -> C:\MyWebApp\MyWebApp\obj\Release\net9.0\PubTmp\Out\
clearSettings.bat C:\Publish\MyWebApp
"appsettings.json not found"
Web App was published successfully file:///C:/Publish/MyWebApp
本文标签: Visual Studio 2022 Community Publish event called too earlyStack Overflow
版权声明:本文标题:Visual Studio 2022 Community Publish event called too early? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738633284a2103877.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论