-
Notifications
You must be signed in to change notification settings - Fork 7
Build and Deploy
Home / Developer / Build and Deploy
The build and deploy setup for the C# code has changed from version 5.7.x to 6.0.0.
When you build there is a dependency on the Solution configurations in Visual Studio.
For example, if you want to build Test, choose the Test Solution Configuration in Visual Studio(see Test in image below) and the Test build will be built in the <ROOT_DIRECTORY>/server/PxStat/bin/Test/net6.0(where <ROOT_DIRECTORY> is the root directory of the PxStat checkout. This build will have all of the configuration files needed to run the Test build. i.e. appSettings.json, log4net.xml and web.config. These files will contain the correct settings for the Test environment.
The table shows the different build locations for the different environments based on their Solution configurations.
Environment | Solution configuration | Build Location |
---|---|---|
Debug | Debug | bin/net6.0 |
Demo | Demo | bin/Demo/net6.0 |
Dev | Dev | bin/Dev/net6.0 |
Live | Live | bin/Live/net6.0 |
Test | Test | bin/Test/net6.0 |
UAT | UAT | bin/UAT/net6.0 |
The build file <ROOT_DIRECTORY>/server/PxStat/PxStat.csproj, is used, to build, to all the different environments.
This .csproj file uses targets to copy or remove various configuration files to correctly build PxStat for the specific environment.
For example, to build the Test environment the targets CopyTestAppSettings, RemoveAppSettings and RemoveConfig are used:
<Target Name="CopyTestAppSettings" AfterTargets="Build" Condition="'$(Configuration)'=='Test'">
<Message Text="Copying $(Outdir)appsettings.Test.json to $(Outdir)appsettings.json" />
<Copy SourceFiles="$(Outdir)appsettings.Test.json" DestinationFiles="$(Outdir)appsettings.json" Condition="Exists('$(Outdir)appsettings.Test.json')" />
<Copy SourceFiles="$(Outdir)log4net.Test.config" DestinationFiles="$(Outdir)log4net.config" Condition="Exists('$(Outdir)log4net.Test.config')" />
</Target>
The CopyTestAppSettings target will be run after the build target and is conditional on the Test Solution configuration being set in Visual Studio.
$(Outdir) is a Visual Studio Build Property Macro. This corresponds to the <ROOT_DIRECTORY>/server/PxStat/bin/Test/net6.0 directory.
The Copy tag copies the <ROOT_DIRECTORY>/server/PxStat/bin/Test/net6.0/appsettings.Test.json to the <ROOT_DIRECTORY>/server/PxStat/bin/Test/net6.0/appsettings.json on condition that <ROOT_DIRECTORY>/server/PxStat/bin/Test/net6.0/appsettings.Test.json exists.
The second Copy tag copies the <ROOT_DIRECTORY>/server/PxStat/bin/Test/net6.0/log4net.Test.config to the <ROOT_DIRECTORY>/server/PxStat/bin/Test/net6.0/log4net.config on condition that <ROOT_DIRECTORY>/server/PxStat/bin/Test/net6.0/log4net.Test.config exists.
<Target Name="RemoveAppSettings" AfterTargets="Build">
<Delete Files="$(OutDir)appsettings.Debug.json" />
<Delete Files="$(OutDir)appsettings.Test.json" />
<Delete Files="$(OutDir)appsettings.UAT.json" />
<Delete Files="$(OutDir)appsettings.Demo.json" />
<Delete Files="$(OutDir)appsettings.Live.json" />
<Delete Files="$(OutDir)appsettings.Dev.json" />
</Target>
The RemoveAppSettings target will be run after the build target and is used to delete unnecessary files in the build output directory. The Delete tags delete the files appsettings.Debug.json, appsettings.Test.json, appsettings.UAT.json, appsettings.Demo.json, appsettings.Live.json and appsettings.Dev.json in the build output directory.
<Target Name="RemoveConfig" AfterTargets="Build">
<Delete Files="$(OutDir)log4net.Live.config" />
<Delete Files="$(OutDir)log4net.Test.config" />
<Delete Files="$(OutDir)log4net.Demo.config" />
<Delete Files="$(OutDir)log4net.UAT.config" />
<Delete Files="$(OutDir)web.Live.config" />
</Target>
The RemoveConfig target will be run after the build target and is used to delete unnecessary files in the build output directory. The Delete tags delete the files log4net.Live.config, log4net.Test.config, log4net.Demo.config, log4net.UAT.config and web.Live.config in the build output directory.
Note: There are other targets in the .csproj file for the other environments. These targets can be slightly different for the various environments.
When you deploy or publish there is a dependency on the Solution configurations in Visual Studio.
For example if you want to publish Test, choose the Test Solution in Visual Studio and the Test build will be built in the <ROOT_DIRECTORY>/server/PxStat/bin/Test/net6.0(where <ROOT_DIRECTORY> is the root directory of the PxStat checkout. This publication will have all of the configuration files needed to run the Test build. i.e. appSettings.json, log4net.xml and web.config. These files will contain the correct settings for the Test environment.
The publish file _**<ROOT_DIRECTORY>/server/PxStat/Properties/PublishProfiles/Test.pubxml, is used, to publish, to the Test environment.
The table shows the different names for the publish files for the different environments based on their Solution configurations.
Environment | Solution configuration | Publish Location |
---|---|---|
Demo | Demo | <ROOT_DIRECTORY>/server/PxStat/Properties/PublishProfiles/Demo.pubxml |
Dev | Dev | <ROOT_DIRECTORY>/server/PxStat/Properties/PublishProfiles/Dev.pubxml |
Live | Live | <ROOT_DIRECTORY>/server/PxStat/Properties/PublishProfiles/Live.pubxml |
Test | Test | <ROOT_DIRECTORY>/server/PxStat/Properties/PublishProfiles/Test.pubxml |
UAT | UAT | <ROOT_DIRECTORY>/server/PxStat/Properties/PublishProfiles/UAT.pubxml |
The publish file uses an ItemGroup and a Target tag to prepare the PxStat output directory before publishing.
<ItemGroup>
<Content Update="appsettings.json" CopyToPublishDirectory="Never" />
<Content Update="appsettings.Debug.json" CopyToPublishDirectory="Never" />
<Content Update="appsettings.Demo.json" CopyToPublishDirectory="Never" />
<Content Update="appsettings.Dev.json" CopyToPublishDirectory="Never" />
<Content Update="appsettings.Live.json" CopyToPublishDirectory="Never" />
<Content Update="appsettings.Test.json" CopyToPublishDirectory="Never" />
<Content Update="appsettings.UAT.json" CopyToPublishDirectory="Never" />
<Content Update="log4net.Live.config" CopyToPublishDirectory="Never" />
<Content Update="log4net.UAT.config" CopyToPublishDirectory="Never" />
<Content Update="log4net.Demo.config" CopyToPublishDirectory="Never" />
<Content Update="log4net.Test.config" CopyToPublishDirectory="Never" />
<Content Update="web.Live.config" CopyToPublishDirectory="Never" />
</ItemGroup>
The ItemGroup specifies the files that should not be copied to the publish directory.
<Target Name="CopyTestAppSettings" AfterTargets="AfterPublish">
<Copy SourceFiles="appsettings.Test.json" DestinationFiles="appsettings.json"></Copy>
<Copy SourceFiles="appsettings.Test.json" DestinationFiles="$(publishUrl)appsettings.json"></Copy>
<Copy SourceFiles="log4net.Test.config" DestinationFiles="log4net.config"></Copy>
<Copy SourceFiles="log4net.Test.config" DestinationFiles="$(publishUrl)log4net.config"></Copy>
<Copy SourceFiles="web.config" DestinationFiles="$(publishUrl)web.config"></Copy>
</Target>
The CopyTestAppSettings target copies files from the $(OutputDir) to the $(publishUrl) directory. The $(publishUrl) is a field in the PropertyGroup tag.
<PropertyGroup>
<WebPublishMethod>FileSystem</WebPublishMethod>
<PublishProvider>FileSystem</PublishProvider>
<LastUsedBuildConfiguration>Test</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<SiteUrlToLaunchAfterPublish />
<LaunchSiteAfterPublish>true</LaunchSiteAfterPublish>
<ExcludeApp_Data>false</ExcludeApp_Data>
<publishUrl>\\serverIP\inetpub\cso.ie\test-ws-netcore\server</publishUrl>
<DeleteExistingFiles>true</DeleteExistingFiles>
<TargetFramework>net6.0</TargetFramework>
<ProjectGuid>41c45653-c643-45b8-902d-4755a647f0fb</ProjectGuid>
<SelfContained>false</SelfContained>
</PropertyGroup>
To copy the appsettings.Test.json from the $(OutDir) to the $(publishUrl) and be renamed to appsettings.json, two copy tags, are used:
<Copy SourceFiles="appsettings.Test.json" DestinationFiles="appsettings.json"></Copy>
<Copy SourceFiles="appsettings.Test.json" DestinationFiles="$(publishUrl)appsettings.json"></Copy>
The first copy, copies appsettings.Test.json to appsettings.json. the second copy copies appsettings.Test.json to $(publishUrl)appsettings.json.
Update
Database Scripts
Configuration
API
- Home
- Data
- Security
- Subscription
- System
- Navigation
- Notification
- Settings
- Workflow
- Px Build
Developer
- Home
- Developer Tools
- Client Tier
- Server Tier
- Database Tier