...
- Install the tool via dotnet cli:
- dotnet tool install -g Project2015To2017.Migrate2019.Tool\
- Then to run the conversion:
- dotnet migrate-2019 wizard old-output-path C:\src\rm3\riversystem\Solutions\<solution>.sln
- Tidy up using regex:
<ReferencePath>$(RootPath)3rdParty</ReferencePath> → <AssemblySearchPaths>$(RootPath)3rdParty;$(AssemblySearchPaths);</AssemblySearchPaths>
- Make additional changes as outlined in Notes for the the New Format section below.
- Remove duplicate entries which are often added by removing and collapsing the Release and Debug sections.
- Remove old junk which isn't needed anymore.
...
- TargetFramework - net48
- LangVersion - 7.3NoWarn - 1591,1587
- 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<Import Project="$(RootPath)RiverSystem\Solutions\NormalisePdbBuildRoot.targets" /
> is set- References to projects within the same solution are set using ProjectReference entires e.g.
<ProjectReference Include="..\TIME\TIME.csproj" />
- dll references are set with
- private = false
- specific version = false
...
<Import Project="$(RootPath)RiverSystem\Solutions\UnitTests.props" />
is set for projects containing unit tests<Import Project="$(RootPath)RiverSystem\Solutions\SDKUnitTests.build.propstargets" />
- 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 theSDK.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) 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
- References to projects within the same solution are set using ProjectReference entires e.g.
<ProjectReference Include="..\TIME\TIME.csproj" />
- dll references are set with
- private = false
- specific version = false
Additional Notes:
<Import Project="$(RootPath)RiverSystem\Solutions\NormalisePdbBuildRootSDK.build.targetsprops" />
- to configure the normalization of pdb build paths
- 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 "
- Remove individual entries for resources
Add entries using wildcards for resources if they exist similar to the following:
Code Block | ||
---|---|---|
| ||
<ItemGroup>
<EmbeddedResource Include="Persistence\Mappings\*.hbm.xml" />
<EmbeddedResource Include="Persistence\SchemaUpgrades\*.sql" />
<Resource Include="Resources\**\*">
<Pack>True</Pack>
</Resource>
</ItemGroup> |
Example:
...
title | New csproj example |
---|
...
language | xml |
---|---|
linenumbers | true |
...
- 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.