-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- organize targets into seperate files - support restore plugins via Directory.Solution.targets - set `PublishRelease` msbuild prop by default
- Loading branch information
Showing
9 changed files
with
277 additions
and
214 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
|
||
<PropertyGroup> | ||
<PluginSdkCommonTargetsHasBeenImported>true</PluginSdkCommonTargetsHasBeenImported> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup> | ||
<PluginManagerDataDir Condition=" '$(PluginManagerDataDir)' == '' AND '$(PluginManager)' == 'r2modman' ">$(AppData)\r2modmanPlus-local\LethalCompany\</PluginManagerDataDir> | ||
<PluginManagerDataDir Condition=" '$(PluginManagerDataDir)' == '' ">$(AppData)\Thunderstore Mod Manager\DataFolder\LethalCompany\</PluginManagerDataDir> | ||
|
||
<PluginCacheDir Condition=" '$(PluginCacheDir)' == '' AND '$(PLUGIN_SDK_CACHE)' != '' ">$([MSBuild]::EnsureTrailingSlash($(PLUGIN_SDK_CACHE)))</PluginCacheDir> | ||
<PluginCacheDir Condition=" '$(PluginCacheDir)' == '' ">$(PluginManagerDataDir)cache\</PluginCacheDir> | ||
<PluginProfileDir Condition=" '$(PluginStagingProfile)' != '' AND '$(PluginProfileDir)' == '' AND '$(PluginManagerDataDir)' != '' ">$(PluginManagerDataDir)profiles\$(PluginStagingProfile)\</PluginProfileDir> | ||
|
||
<PluginDescription Condition=" '$(PluginDescription)' == '' ">$(Description)</PluginDescription> | ||
<PluginId Condition=" '$(PluginId)' == '' ">$(AssemblyName)</PluginId> | ||
|
||
<!-- NOTE: backwards compatibility with renaming PluginInfoTypeAccessModifier -> PluginInfoModifiers --> | ||
<PluginInfoTypeModifiers Condition=" '$(PluginInfoTypeModifiers)' == '' ">$(PluginInfoTypeAccessModifier)</PluginInfoTypeModifiers> | ||
<PluginInfoTypeModifiers Condition=" '$(PluginInfoTypeModifiers)' == '' ">internal static</PluginInfoTypeModifiers> | ||
<PluginInfoTypeName Condition=" '$(PluginInfoTypeName)' == '' ">GeneratedPluginInfo</PluginInfoTypeName> | ||
|
||
<PluginName Condition=" '$(PluginName)' == '' ">$(Title)</PluginName> | ||
<PluginName Condition=" '$(PluginName)' == '' ">$(Product)</PluginName> | ||
<PluginName Condition=" '$(PluginName)' == '' ">$(AssemblyName)</PluginName> | ||
|
||
<PluginChangeLogFile Condition=" '$(PluginChangeLogFile)' == '' ">CHANGELOG.md</PluginChangeLogFile> | ||
<PluginReadMeFile Condition=" '$(PluginReadMeFile)' == '' ">$(PackageReadMeFile)</PluginReadMeFile> | ||
<PluginReadMeFile Condition=" '$(PluginReadMeFile)' == '' ">README.md</PluginReadMeFile> | ||
<PluginVersion Condition=" '$(PluginVersion)' == '' ">$(Version)</PluginVersion> | ||
|
||
<!-- Thunderstore metadata --> | ||
<ThunderDescription Condition=" '$(ThunderDescription)' == '' ">$(PluginDescription)</ThunderDescription> | ||
<ThunderId Condition=" '$(ThunderId)' == '' ">$(PackageId)</ThunderId> | ||
<ThunderId Condition=" '$(ThunderId)' == '' ">$(PluginId)</ThunderId> | ||
<ThunderVersion Condition=" '$(ThunderVersion)' == '' ">$(PluginVersion)</ThunderVersion> | ||
<ThunderWebsiteUrl Condition=" '$(ThunderWebsiteUrl)' == '' ">$(PackageProjectUrl)</ThunderWebsiteUrl> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<Content Include="$(PluginChangeLogFile)" Condition=" '$(PluginChangeLogFile)' != '' AND Exists('$(MSBuildProjectDirectory)\$(PluginChangeLogFile)') "> | ||
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory> | ||
</Content> | ||
|
||
<Content Include="icon.png;$(PluginReadMeFile)"> | ||
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory> | ||
</Content> | ||
</ItemGroup> | ||
|
||
<ItemGroup Condition=" '$(ImplicitUsings)' == 'true' OR '$(ImplicitUsings)' == 'enable' "> | ||
<Using Include="System.Collections" /> | ||
<Using Include="BepInEx" /> | ||
<Using Include="HarmonyLib" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="Common.targets" Condition=" '$(PluginSdkCommonTargetsHasBeenImported)' != 'true' " /> | ||
|
||
<PropertyGroup> | ||
<PluginSdkGenerateTargetsHasBeenImported>true</PluginSdkGenerateTargetsHasBeenImported> | ||
</PropertyGroup> | ||
|
||
<!-- | ||
Executes the `GeneratePluginInfoCode` task to generate a type containing plugin metadata defined via MSBuild properties. | ||
--> | ||
<Target Name="_GeneratePluginInfo" BeforeTargets="BeforeCompile;CoreCompile" Inputs="$(MSBuildAllProjects)" Outputs="$(IntermediateOutputPath)$(MSBuildProjectName).PluginInfo.g.cs"> | ||
<ItemGroup> | ||
<Compile Include="$(IntermediateOutputPath)$(MSBuildProjectName).PluginInfo.g.cs" /> | ||
<FileWrites Include="$$(IntermediateOutputPath)$(MSBuildProjectName).PluginInfo.g.cs" /> | ||
</ItemGroup> | ||
|
||
<GeneratePluginInfoCode Identifier="$(PluginId)" Name="$(PluginName)" Namespace="$(RootNamespace)" Version="$(PluginVersion)" TypeModifiers="$(PluginInfoTypeModifiers)" TypeName="$(PluginInfoTypeName)"> | ||
<Output PropertyName="_GeneratedPluginInfoCode" TaskParameter="GeneratedText" /> | ||
</GeneratePluginInfoCode> | ||
<WriteLinesToFile File="$(IntermediateOutputPath)$(MSBuildProjectName).PluginInfo.g.cs" Lines="$(_GeneratedPluginInfoCode)" Overwrite="true" WriteOnlyWhenDifferent="true" Condition=" '$(_GeneratedPluginInfoCode)' != '' " /> | ||
</Target> | ||
|
||
<!-- | ||
Executes the `GeneratePluginManifestJson` task to generate the json text of the `manifest.json` used when publishing a Thunderstore package. | ||
--> | ||
<Target Name="_GeneratePluginManifest" BeforeTargets="BeforeCompile;CoreCompile" Inputs="$(MSBuildAllProjects)" Outputs="$(IntermediateOutputPath)$(MSBuildProjectName).manifest.g.json"> | ||
<ItemGroup> | ||
<Content Include="$(IntermediateOutputPath)$(MSBuildProjectName).manifest.g.json"> | ||
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory> | ||
<Link>manifest.json</Link> | ||
<Visible>false</Visible> | ||
</Content> | ||
<FileWrites Include="$(IntermediateOutputPath)$(MSBuildProjectName).manifest.g.json" /> | ||
</ItemGroup> | ||
|
||
<GeneratePluginManifestJson Dependencies="@(ThunderDependency)" Description="$(ThunderDescription)" Name="$(ThunderId)" Version="$(ThunderVersion)" WebsiteUrl="$(ThunderWebsiteUrl)"> | ||
<Output PropertyName="_GeneratedManifestJson" TaskParameter="GeneratedText" /> | ||
</GeneratePluginManifestJson> | ||
<WriteLinesToFile File="$(IntermediateOutputPath)$(MSBuildProjectName).manifest.g.json" Lines="$(_GeneratedManifestJson)" Overwrite="true" WriteOnlyWhenDifferent="true" Condition=" '$(_GeneratedManifestJson)' != '' " /> | ||
</Target> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="Common.targets" Condition=" '$(PluginSdkCommonTargetsHasBeenImported)' != 'true' " /> | ||
|
||
<PropertyGroup> | ||
<PluginSdkPublishTargetsHasBeenImported>true</PluginSdkPublishTargetsHasBeenImported> | ||
</PropertyGroup> | ||
|
||
<!-- NOTE: enforce optimizations in release mode --> | ||
<PropertyGroup Condition=" '$(Configuration)' == 'Release' AND '$(DisableReleaseOptimizations)' != 'true' "> | ||
<DebugType>none</DebugType> | ||
<DebugSymbols>false</DebugSymbols> | ||
<IncludeSymbols>false</IncludeSymbols> | ||
<Optimize>true</Optimize> | ||
</PropertyGroup> | ||
|
||
<!-- | ||
Configures properties+directories required for publishing a Thunderstore package. | ||
--> | ||
<Target Name="PrepareForPluginPublish" BeforeTargets="PrepareForPublish;PublishPlugin"> | ||
<PropertyGroup> | ||
<_PublishDir>$([MSBuild]::EnsureTrailingSlash('$(PublishDir)'))</_PublishDir> | ||
<PublishDir>$(OutputPath)publish\</PublishDir> | ||
|
||
<PluginStagingDir Condition=" '$(PluginStagingProfile)' != '' ">$(PluginProfileDir)BepInEx\plugins\$(ThunderId)\</PluginStagingDir> | ||
<StagePlugin Condition=" '$(StagePlugin)' != 'false' AND '$(PluginStagingProfile)' != '' ">true</StagePlugin> | ||
|
||
<_PluginPackage>$(_PublishDir)$(ThunderId)-$(PluginVersion).zip</_PluginPackage> | ||
|
||
<!-- NOTE: a custom output path was NOT specified, place the archive in 'bin\', rather than 'bin\publish\' (can't place archive in the folder being archived) --> | ||
<_PluginPackage Condition=" '$(PublishDir)' == '$(_PublishDir)' ">$(OutputPath)$(ThunderId)-$(PluginVersion).zip</_PluginPackage> | ||
</PropertyGroup> | ||
|
||
<MakeDir Directories="$(_PublishDir)" Condition=" '$(StagePlugin)' != 'true' " /> | ||
</Target> | ||
|
||
<!-- | ||
Copies custom build assets to the publish directory, prior to the default publishing process. | ||
--> | ||
<Target Name="_CopyToPublishDir" AfterTargets="Publish" BeforeTargets="PublishPlugin"> | ||
<Copy SourceFiles="$(IntermediateOutputPath)$(MSBuildProjectName).manifest.g.json" DestinationFiles="$(PublishDir)manifest.json" SkipUnchangedFiles="true" Condition=" Exists('$(IntermediateOutputPath)$(MSBuildProjectName).manifest.g.json') " /> | ||
</Target> | ||
|
||
<!-- | ||
Creates a Thunderstore package from the content of the default publish directory. | ||
--> | ||
<Target Name="PublishPlugin" AfterTargets="Publish"> | ||
<Warning Code="LC001" Text="Plugin was not built in Release mode, users may experience an impact to performance!" Condition=" '$(Configuration)' != 'Release' AND '$(StagePlugin)' != 'true' AND '$(DisableReleaseOptimizations)' != 'true' " /> | ||
|
||
<Error Text="Failed to Stage Plugin, PluginStagingProfile directory '$(PluginProfileDir)' does not exist." Condition=" '$(StagePlugin)' == 'true' AND !Exists('$(PluginProfileDir)') " /> | ||
<MakeDir Directories="$(PluginStagingDir)" /> | ||
|
||
<!-- clean --> | ||
<ItemGroup> | ||
<_PublishFilesToDelete Include="$(PublishDir)\$(AssemblyName).deps.json" /> | ||
<_PublishFilesToDelete Include="$(PublishDir)\*.pdb" Condition=" '$(Configuration)' == 'Release' " /> | ||
</ItemGroup> | ||
<Delete Files="@(_PublishFilesToDelete)" /> | ||
|
||
<ItemGroup> | ||
<_PluginFiles Include="$(PublishDir)\**\*.*" /> | ||
<_PluginStagingDirFiles Include="$(PluginStagingDir)**\*.*" Condition=" '$(StagePlugin)' == 'true' " /> | ||
</ItemGroup> | ||
|
||
<!-- stage --> | ||
<Delete Files="@(_PluginStagingDirFiles)" Condition=" '$(StagePlugin)' == 'true' " /> | ||
<Copy SourceFiles="@(_PluginFiles)" DestinationFiles="@(_PluginFiles -> '$(PluginStagingDir)%(RecursiveDir)%(Filename)%(Extension)')" SkipUnchangedFiles="true" Condition=" '$(StagePlugin)' == 'true' " /> | ||
|
||
<Message Importance="High" Text="$(ThunderId) -> $(PluginStagingDir)" Condition=" '$(StagePlugin)' == 'true' " /> | ||
|
||
<!-- package --> | ||
<ZipDirectory SourceDirectory="$(PublishDir)" DestinationFile="$(_PluginPackage)" Overwrite="true" Condition=" '$(StagePlugin)' != 'true' " /> | ||
</Target> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="Sdk.tasks" Condition=" '$(PluginSdkAssemblyHasBeenImported)' != 'true' " /> | ||
<Import Project="Common.targets" Condition=" '$(PluginSdkCommonTargetsHasBeenImported)' != 'true' " /> | ||
|
||
<PropertyGroup> | ||
<PluginSdkRestoreTargetsHasBeenImported>true</PluginSdkRestoreTargetsHasBeenImported> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup> | ||
<RestorePluginsWithLockFile Condition=" '$(RestorePluginsWithLockFile)' == '' AND '$(RestorePackagesWithLockFile)' == 'true' ">true</RestorePluginsWithLockFile> | ||
<PluginLockFile Condition=" '$(RestorePluginsWithLockFile)' == 'true' AND '$(PluginLockFile)' == '' ">$(MSBuildProjectDirectory)\plugins.lock.json</PluginLockFile> | ||
<PluginLockFile Condition=" '$(RestorePluginsWithLockFile)' != 'true' "></PluginLockFile> | ||
|
||
<PluginAssetsFile>$(MSBuildProjectDirectory)\$(BaseIntermediateOutputPath)plugin.assets.json</PluginAssetsFile> | ||
<PluginRestoreOutputs>$(PluginRestoreOutputs);$(PluginAssetsFile);</PluginRestoreOutputs> | ||
<PluginRestoreOutputs Condition=" '$(PluginLockFile)' != '' ">$(PluginRestoreOutputs)$(PluginLockFile);</PluginRestoreOutputs> | ||
|
||
<ResolveAssemblyReferencesDependsOn>$(ResolveAssemblyReferencesDependsOn)ResolvePluginReferences;</ResolveAssemblyReferencesDependsOn> | ||
</PropertyGroup> | ||
|
||
<!-- | ||
Executes the `RestorePluginDependencies` task to restore `ThunderDependency` items | ||
--> | ||
<Target Name="RestorePlugins" BeforeTargets="Restore" AfterTargets="_GetAllRestoreProjectPathItems" Inputs="$(MSBuildAllProjects)" Outputs="$(PluginRestoreOutputs)"> | ||
<ItemGroup> | ||
<FileWrites Include="$(PluginLockFile)" Condition=" '$(PluginLockFile)' != '' " /> | ||
<FileWrites Include="$(PluginAssetsFile)" /> | ||
</ItemGroup> | ||
|
||
<RestorePluginDependencies CacheDirectory="$(PluginCacheDir)" Dependencies="@(ThunderDependency)" LockedMode="$(RestoreLockedMode)" PluginLockFile="$(PluginLockFile)" WithLockFile="$(RestorePluginsWithLockFile)"> | ||
<Output PropertyName="_GeneratedAssetsJson" TaskParameter="GeneratedAssetsJson" /> | ||
</RestorePluginDependencies> | ||
<WriteLinesToFile File="$(PluginAssetsFile)" Lines="$(_GeneratedAssetsJson)" Overwrite="true" WriteOnlyWhenDifferent="true" Condition=" '$(_GeneratedAssetsJson)' != '' " /> | ||
</Target> | ||
|
||
<!-- | ||
Executes the `ResolvePluginAssemblies` task to resolve the reference assemblies of `ThunderDependency` items. | ||
--> | ||
<Target Name="ResolvePluginReferences" BeforeTargets="CoreCompile" AfterTargets="RestorePlugins;Restore" DependsOnTargets="ResolveProjectReferences"> | ||
<ResolvePluginAssemblies AssetsFile="$(PluginAssetsFile)"> | ||
<Output ItemName="_PluginReference" TaskParameter="ResolvedAssemblies" /> | ||
</ResolvePluginAssemblies> | ||
|
||
<ItemGroup> | ||
<Reference Include="@(_PluginReference)" Private="false" /> | ||
</ItemGroup> | ||
</Target> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.