我需要根据选择的构建配置从launchSettings.json中选择配置文件。假设我有build config Debug,Debug-2,我需要从launchSettings.json中为它们选择不同的配置文件。有没有办法做到这一点?
发布于 2021-05-14 16:51:58
在构建过程中,我使用“复制”MSBuild任务用调试版本或发布版本覆盖launchSettings.json:
<ItemGroup>
<UpToDateCheckInput Include="Properties/launchSettings.$(Configuration).json" />
</ItemGroup>
<Target Name="CleanLaunchSettings" AfterTargets="Clean">
<Message Importance="high" Text="Deleting launchSettings.json..." />
<Delete Files="Properties/launchSettings.json" />
</Target>
<Target Name="CopyLaunchSettings" AfterTargets="Build" Inputs="Properties/launchSettings.$(Configuration).json" Outputs="Properties/launchSettings.json">
<Message Importance="high" Text="Copying launchSettings.$(Configuration).json..." />
<Copy SourceFiles="Properties/launchSettings.$(Configuration).json" DestinationFiles="Properties/launchSettings.json" />
</Target>
https://stackoverflow.com/questions/61867007
复制