Old Format
The pre visual studio 2017 format that was used by source before 2020 was maintained by ProjectChecker.exe on teamcity (and locally).
The core settings that were maintained were:
- Target Framework - .Net 4.8
- Tools Version - 15.0
- LangVersion - C# 7.3, VB 15
- General settings including WarningLevel, NoWarn, Prefer32Bit, Debug symbols, Optimize, etc.
- RootPath - the root of our folder structure which all of our repository folders sit in; defined as a relative path from the project file location.
- Import NormailsePdbBuildRoot targets
- Output paths
- Core projects -> $(RootPath)Output
- Core Plugin projects -> $(RootPath)Output\Plugins
- Community Plugin projects -> $(RootPath)Output\Plugins\CommunityPlugins
- ReferencePath (output path isn't needed to be included as it's automatically used)
- Core projects -> $(RootPath)3rdParty
- Plugins -> $(RootPath)Output;$(RootPath)3rdParty
- Project references
- Convert dll references to project references if within same solution
- Convert project references to dll references if within different solution (cannot use project references as the the build configuration to use is defined in the solution not the project i.e. debug will be used by default when building release)
- Set copy local (private) to false
- Dll references
- Remove version and PublicKeyToken information
- Remove HintPath
- Set specific version to false
- Set copy local (private) to false if part of .Net framework
- Source solution
- Set copy local (private) to true if not part of .Net framework
- Plugins solution
- Set copy local (private) to false if project from Source solution
- Set copy local (private) to false if (directly) referenced by project from Source solution
- Set copy local (private) to true for everything else (i.e. only referenced by a plugin)
Note: ProjectChecker.exe was only run on Source.sln and SourceCommunityPlugins.sln (i.e. doesn't get run on the Not to be distributed plugins).
Expand | |||||||||
---|---|---|---|---|---|---|---|---|---|
| |||||||||
|
New Format
The new format released with Visual Studio 2019.
Main changes are:
- cs files are included by default. They need to be included if you are doing special things with them (e.g. linking xaml files to their cs backing file)
- project references now bring in implicit references of what it references (e.g. A →B and B → C, now A implicitly references C)
- this includes everything C references as well (e.g. if C reference wpf then A will reference wpf)
- Choose/When msbuild constructs don't seem to work the same
- AssemblySearchPaths is used instead of ReferencePaths
Things to look for during dev review:
- TargetFramework - net48
- LangVersion - 7.3
- RootPath - depends on csproj and sln location
- AssemblySearchPaths - includes RootPath/3rdParty
- OutputPath - RootPath/Output
- AssemblyTitle - not needed if the same as the csproj file name (minus the extension)
<Import Project="$(RootPath)RiverSystem\Solutions\SDK.build.props" />
is set<Import Project="$(RootPath)RiverSystem\Solutions\SDK.build.targets" />
is set<Import Project="$(RootPath)RiverSystem\Solutions\SDKIncludeGlobalAssembly.targets" />
is set<Import Project="$(RootPath)RiverSystem\Solutions\IncludeGlobalAssembly.targets" />
is not set removed<Import Project="$(RootPath)RiverSystem\Solutions\NormalisePdbBuildRoot.targets" /
> is set<Import Project="$(RootPath)RiverSystem\Solutions\UnitTests.props" />
is set for projects containing unit tests<Import Project="$(RootPath)RiverSystem\Solutions\UnitTests.targets" />
is set for projects containing unit tests<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
is removed (will have been added in unit test projects by old versions of Visual Studio)<Reference Include="nunit.framework">
is removed- All properties from the project imports are not set in the csproj file also, should only be set if overriding a setting from the import
- References to projects within the same solution are set using ProjectReference entires e.g.
<ProjectReference Include="..\TIME\TIME.csproj" />
- Core framework dll references are set with
- private = false
- specific version = false
- Other 3rd party dll references are set with (unless the project is a plugin project and the dll is referenced by a core Source project, see ProjectCheck replacement below)
- private = false
- specific version = false
Additional Notes:
<Import Project="$(RootPath)RiverSystem\Solutions\SDK.build.props" />
- AppendTargetFrameworkToOutputPath, AppendRuntimeIdentifierToOutputPath and WarningsAsErrors are set by
SDK.build.props
- this is to stop the /win/x64 folders from being generated
- AppendTargetFrameworkToOutputPath, AppendRuntimeIdentifierToOutputPath and WarningsAsErrors are set by
<Import Project="$(RootPath)RiverSystem\Solutions\SDKIncludeGlobalAssembly.targets" />
- to set the global assembly - no AssemblyInfo.cs is required anymore - these properties are set in the csproj file now
<Import Project="$(RootPath)RiverSystem\Solutions\SDK.build.targets" />
- Copy 3rdParty to output is done via the
SDK.build.targets
- this is done since the Choose/When directives don't seem to work when running the builds via cake/msbuild (they work ok with visual studio 2017/2019)
- Copy 3rdParty to output is done via the
<Import Project="$(RootPath)RiverSystem\Solutions\NormalisePdbBuildRoot.targets" />
- to configure the normalization of pdb build paths
- For unit test projects
- Add
<Import Project="$(RootPath)RiverSystem\Solutions\UnitTests.props" />
- Add
<Import Project="$(RootPath)RiverSystem\Solutions\UnitTests.targets" />
- Remove
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
- Remove <Reference Include="nunit.framework">
- Add
- Compile Remove="file.cs" should be deleted and the "file.cs" should be deleted from the git repo as well.
- For projects containing WPF or WinForms make the the following changes:
- Change the SDK from "
Microsoft.NET.Sdk
" to "MSBuild.Sdk.Extras/3.0.38
" (from https://www.nuget.org/packages/MSBuild.Sdk.Extras) - For WPF add
<UseWPF>true</UseWPF>
to thePropertyGroup
- For WinForms add
<UseWindowsForms>true</UseWindowsForms>
to thePropertyGroup
- Remove
EmbeddedResource
entreies for ".resx" files and the associatedCompile
of ".designer.resx" files - Remove
Compile
entries of ".cs"UserControl
,Form
andComponent
files and associated ".designer.cs" files - Remove
Compile
entries of ".xaml.cs" files and associated ".xaml"Page
files
- Change the SDK from "
Add entries using wildcards for resources if they exist similar to the following:
Code Block language xml <ItemGroup> <EmbeddedResource Include="Persistence\Mappings\*.hbm.xml" /> <EmbeddedResource Include="Persistence\SchemaUpgrades\*.sql" /> <Resource Include="Resources\**\*"> <Pack>True</Pack> </Resource> </ItemGroup>
- Remove individual entries for resources
Example:
Expand | |||||||
---|---|---|---|---|---|---|---|
| |||||||
|
ProjectChecker replacement
ProjectChecker has been modifed to skip SDK format projects. This means that incorrect settings are no longer going to be reported in the TeamCity ProjectChecker build. In particular this means that copy local setting errors will not be reported. ProjectChecker wasn't able to properly handle secondary / indirect references so the copy local settings didn't always work properly anyway. As a replacement there is a build task in the RiverSystem\Build\Scripts\SourceTargets.cake file
, "__CleanDuplicatesFromPluginFolders". This task will delete files from the plugin output folders which are also in the base output folder. Any files deleted will be reported in the build log but there won't be a warning or error when this occurs. We could change this to report a build warning on TeamCity. Unneeded references can be checked by doing a local cake build (using PowerShell in the RiverSystem\Build\Scripts
folder): .\SourceTargets.ps1 --target=BuildSourceAndPlugins --configuration=Debug