Coder Social home page Coder Social logo

hvanbakel / csprojtovs2017 Goto Github PK

View Code? Open in Web Editor NEW
1.1K 34.0 123.0 923 KB

Tooling for converting pre 2017 project to the new Visual Studio 2017 format.

License: MIT License

C# 100.00% Smalltalk 0.01%
conversion visual-studio-2017 csproj-tooling csproj migration migrate

csprojtovs2017's Introduction

Build status NuGet Version NuGet Downloads VS15 Global Tool NuGet Version VS15 Global Tool NuGet Downloads VS16 Global Tool NuGet Version VS16 Global Tool NuGet Downloads

Convert your old project files to the new 2017/2019 format

With the introduction of Visual Studio 2017, Microsoft added some optimizations to how a project file can be set up. However, no tooling was made available that performed this conversion as it was not necessary to do since Visual Studio 2017 would work with the old format too.

This project converts an existing csproj to the new format, shortening the project file and using all the nice new features that are part of modern Visual Studio versions.

What does it fix?

There are a number of things that VS2017+ handles differently that are performed by this tool:

  1. Include files using a wildcard as opposed to specifying every single file
  2. A more succinct way of defining project references
  3. A more succinct way of handling NuGet package references
  4. Moving some of the attributes that used to be defined in AssemblyInfo.cs into the project file
  5. Defining the NuGet package definition as part of the project file

Quick Start

Assuming you have .NET Core 2.1+ installed you can run this on the command line:

> dotnet tool install --global Project2015To2017.Migrate2019.Tool

This will install the tool for you to use it anywhere you would like. You can then call the tool as shown in the examples below.

> dotnet migrate-2019 wizard "D:\Path\To\My\TestProject.csproj"

Or

> dotnet migrate-2019 wizard "D:\Path\To\My\TestProject.sln"

Or

> dotnet migrate-2019 wizard .\MyProjectDirectory

Or even

> dotnet migrate-2019 wizard **\*

This will start the interactive wizard, which will guide you through the conversion process. You will have an option to create backups before all critical conversion stages.

Note: There is no need to specify paths if there is only one convertible object (project or solution) in your current working directory. The tool will discover them automatically, or inform you in case it can't make definite (and safest) decision.

Note: in case you need to migrate to VS2017, not VS2019, install Project2015To2017.Migrate2017.Tool instead. It will provide dotnet migrate-2017 command with a few tiny behavioral differences to support older VS versions.

Commands

  • wizard will run interactive conversion wizard as shown above
  • migrate will run non-interactive migration (useful for scripts or advanced users)
  • evaluate will run evaluation of projects found given the path specified
  • analyze will run analyzers to signal issues in the project files without performing actual conversion

Most likely the only command you would use is the wizard, since it will execute all others in a way to achieve best user experience.

Flags

  • target-frameworks will override the target framework on the outputted project file
  • force-transformations allows specifying individual transforms to be run on the projects
  • force ignores checks like project type being supported and will attempt a conversion regardless
  • keep-assembly-info instructs the migrate logic to keep the assembly info file
  • old-output-path will set AppendTargetFrameworkToOutputPath in converted project file
  • no-backup do not create a backup folder (e.g. when your solution is under source control)

Not all flags are supported by all commands, verify help output of the command to learn which options apply to the particular command.

In case you need to specify multiple values for option, specify it multiple times:

> dotnet migrate-2019 migrate -t net40 -t net45

Use as a NuGet library from your own code

For additional control of the project migration process, you can use the NuGet packages directly from your code.

Add the Project2015To2017.Migrate2019.Library package to your project e.g.

> dotnet add package Project2015To2017.Migrate2019.Library

Then, to apply the default project migration:

using Project2015To2017;
using Project2015To2017.Analysis;
using Project2015To2017.Migrate2017;
using Project2015To2017.Migrate2019.Library;
using Project2015To2017.Writing;

// We use Serilog, but you can use any logging provider
using Serilog;
using Serilog.Extensions.Logging;

namespace Acme.ProjectMigration
{
    class Program
    {
        static void Main(string[] args)
        {
            var logger = new LoggerConfiguration()
                        .Enrich.FromLogContext()
                        .MinimumLevel.Debug()
                        .WriteTo.Console()
                        .CreateLogger();

            var genericLogger = new SerilogLoggerProvider(logger)
                                .CreateLogger(nameof(Serilog));

            var facility = new MigrationFacility(genericLogger);

            facility.ExecuteMigrate(
                new[] { @"C:\full-path-to-solution-or-project-file.sln" },
                Vs16TransformationSet.Instance, // the default set of project file transformations

                // The rest are optional, will use sane defaults if not specified

                new ConversionOptions(), // control over things like target framework and AssemblyInfo treatment
                new ProjectWriteOptions(), // control over backup creation and custom source control logic
                new AnalysisOptions() // control over diagnostics which will be run after migration
            );
        }
    }
}

To provide a custom set of project transforms, provide these to the ExecuteMigrate function call:

var customTransforms = new BasicTransformationSet(
    // Note that these should implement ITransformationWithTargetMoment
    // in order to make sure that they run before or after
    // the majority of standard transforms.

    // You can also implement ITransformationWithDependencies to ensure
    // that your transformation always runs after some other
    // standard or user-specified transformations.

    new MyCustomPreTransform1(),
    new MyCustomPreTransform2(),
    new MyCustomPostTransform1(),
    new MyCustomPostTransform2()
);

// Mix transformations from Vs16TransformationSet and from customTransforms.
// The correct order will be resolved by the library based on
// dependency graph topological ordering within each execution moment
// (early, normal, late).
var resultTransforms = new ChainTransformationSet(
    Vs16TransformationSet.Instance,
    customTransforms
);

facility.ExecuteMigrate(
    new[] { @"C:\full-path-to-solution-or-project-file.sln" },
    resultTransforms
);

csprojtovs2017's People

Contributors

ablanchet avatar andrew-boyarshin avatar baruchiro avatar cdonnellytx avatar conficient avatar cwuethrich avatar dustinsoftware avatar hvanbakel avatar imsh avatar jdlegan avatar jetersen avatar lahma avatar laurencee avatar mbp avatar mungojam avatar ozziepeeps avatar robsonj avatar superstrom avatar tom-englert avatar volkan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

csprojtovs2017's Issues

Imports fail

<Import Project="..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.8\build\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props" Condition="Exists('..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.8\build\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props')" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" />

error : The attribute "xmlns" in element is unrecognized.

Safe reading of packages.config

  • When there is no packages.config, tool causes fatal error
  • When there is a dummy / different packages.config, valid XML but with unexpected tags something like:
    <project></project>
    
    will also cause the fatal error. It could be a non-xml file, a YAML, JSON or anything.

The reading and processing of packages.config should be in try-catch to prevent from these fatalities.

Exception when Nuspec is found

Hi
I got an exception when converting.

Multiple project files found under directory ..\[myfolder]
Found nuget reference to Autofac, version 4.6.2.
Found nuget reference to BCrypt.Net-Next, version 2.1.3.
Found nuget reference to Newtonsoft.Json, version 9.0.1.
No nuspec found, skipping package configuration.
Reading assembly info from [myFolder]\Properties\AssemblyInfo.cs.

Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object.
   at Project2015To2017.Transforms.NugetPackageTransformation.PopulatePlaceHolders(PackageConfiguration rawPackageConfig, AssemblyAttributes assemblyAttributes)
   at Project2015To2017.Transforms.NugetPackageTransformation.Transform(Project definition, IProgress`1 progress)
   at Project2015To2017.ProjectConverter.ProcessFile(String filePath, IProgress`1 progress)
   at Project2015To2017.ProjectConverter.<Convert>d__1.MoveNext()
   at Project2015To2017.Console.Program.Main(String[] args)

Add topics to github

Thanks for this great tool!

It's a bit difficult to find on Github though.

I would recommend to add some Github topics (see here)

Something like this:

  • visual-studio-2107
  • csproj
  • migrate
  • upgrade
  • tool

Custom configurations are not available after migration

After migration, our custom configurations are no longer available in the project properties.
The configurations are still in the project files.
After adding the line <Configurations>Debug;Release;Release_CI</Configurations> in the first PropertyGroup in the project file, we got our custom configuration back.

Crash when OutputType undetermined from csproj

Some projects use conditional property groups to define OutputType, so current implementation does not take it into consideration and crashes. It would be nice to:

  1. provide an option not to crash for single failed project;
  2. try also search in all property groups if unconditional one does not contain stuff, pick first match (please, do not check for mismatches if different values are present for same project, like exe and winexe for debug and release correspondingly).

Shortened example:

...
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <ProjectGuid>{1152B71B-3C05-4598-B20D-823B5D40559E}</ProjectGuid>
    <AssemblyName>SharpDevelop</AssemblyName>
...
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <DebugType>Full</DebugType>
    <Optimize>False</Optimize>
    <OutputType>Exe</OutputType>
    <DebugSymbols>true</DebugSymbols>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <DebugType>None</DebugType>
    <Optimize>True</Optimize>
    <OutputType>WinExe</OutputType>
    <DebugSymbols>false</DebugSymbols>
  </PropertyGroup>
...

TFS TFVC .vspscc files are not being excluded from resultant project

Visual Studio uses vspscc files to keep track of which projects are in TFS (I think that's how it works anyway). In old style projects, these don't get automatically included in projects, so we aren't used to having them there.

When converting, they are then included so I end up explicitly excluding them in the new project file.

I can't decide whether you should add in this exclusion automatically. I have doubts because when I create a new .net standard project in VS, it doesn't exclude these files.

Hopefully we will move to Git soon anyway and not have to worry about it. Until then though, I would quite like to keep them hidden.

Same example project as in #58: ClassLibrary1.zip

PackageReference dependencies should be copied from the old csproj file

When I use your tool with a project which already uses PackageReference, but not the new csproj style, the tool doesn't recognize any nuget packages. Even the existing PackageReference packages are not copied in to the new configuration.

I'm happy your tool creates a backup file of the old csproj file, so I can copy/paste the PackageReference manually. But this could/should be done by the tool itself.

Includes have old csproj namespace

ProjectWriter generates:
<ItemGroup> <None Include="packages.config" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" /> </ItemGroup>

Change solution GUIDs to explicitly specify to open with the new project format

A very minor one, especially as VS maybe fixes it automatically on first open

The GUIDs in the solution file tell VS what type of project loader to use. If we leave it as is, then VS uses some heuristics to figure out that it should actually open with the new SDK-style format loader rather than the legacy one. This can lead to issues as described: dotnet/project-system#1358

The best approach would be to change the GUIDs in the solution file to:
9A19103F-16F7-4668-BE54-9A1E7A4F7556

which is the GUID of the new loader. VS then uses the new project loader regardless and presumably opens the projects a bit quicker.

Full details on VS behaviour:
https://github.com/dotnet/project-system/blob/master/docs/opening-with-cps.md

Don't convert DefineConstants?

Right now the project is looking for the first match of DefineConstants and using that value.

In reality however, in old csproj files there are multiple variants for each build configuration, e.g.:

  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <DebugSymbols>true</DebugSymbols>
    <DebugType>full</DebugType>
    <Optimize>false</Optimize>
    <OutputPath>bin\Debug\</OutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <DebugType>pdbonly</DebugType>
    <Optimize>true</Optimize>
    <OutputPath>bin\Release\</OutputPath>
    <DefineConstants>TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>

In new project file format, these values are already default values (need not be specified) when you build with Debug and Release respectively.

But current logic will make us set DEBUG even for Release builds!

I propose we just remove DefineConstants conversion.
Alternatively we should convert all of the build configuration specific properties.

How does this handle project.json references?

Does this work for all types of projects or only a select list?

Which project types does this work for?

Project.Json does not include references in .csproj files, how does this handle those references?

Use shorter way of switching of GenerateAssemblyInfo

Right now after conversion is have:

<GenerateAssemblyTitleAttribute>false</GenerateAssemblyTitleAttribute> <GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute> <GenerateAssemblyDescriptionAttribute>false</GenerateAssemblyDescriptionAttribute> <GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute> <GenerateAssemblyCopyrightAttribute>false</GenerateAssemblyCopyrightAttribute> <GenerateAssemblyInformationalVersionAttribute>false</GenerateAssemblyInformationalVersionAttribute> <GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute> <GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute> <GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>

and if can be simplified to just:
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>

Should I create PR with this change?

Transitive NuGet dependencies should be omitted

The new csproj format does not require to include dependencies of project dependencies. That makes clear what is needed for the project to function -- and it obviously makes the resulting list much shorter. Tool should check which dependencies are transitive and omit them from the generated csproj.

I can offer the code under MIT/Apache/... . What license do you use?

Remove wildcard resx include?

Any converted project file, whether it contains embedded resource files or not, will contain the lines:

  <ItemGroup>
    <EmbeddedResource Include="**\*.resx" />
  </ItemGroup>

Why is it needed? Maybe we can make some conditional check for whether or not it needs to be there?

TFS TFVC source control bindings are being lost

Source project example attached. TFVC annoyingly needs to have the following 4 tags in the project file. The project converter is removing these tags which means we need to re-add them afterwards.

We use the auto 'SAK' property, but I guess you should leave whatever is set for these tags if they are present.

<PropertyGroup>
...
    <SccProjectName>SAK</SccProjectName>
    <SccLocalPath>SAK</SccLocalPath>
    <SccAuxPath>SAK</SccAuxPath>
    <SccProvider>SAK</SccProvider>
...
</PropertyGroup>

ClassLibrary1.zip

Handle project reference aliases

Old project reference could have following:

 <ProjectReference Include="One.csproj">
      <Name>One</Name>
      <Aliases>global,one</Aliases>
 </ProjectReference>

That should be converted with kept <Aliases> block. Currently it is removed

custom entry in csproj is not migrated and new Projectname.AssemblyInfo.cs is added

I use this task to get the SVN revision and set the assembly versions:

https://chivinou.wordpress.com/2008/08/06/automatic-assembly-version-number/

<PropertyGroup>
    <MajorNumber>1</MajorNumber>
    <MinorNumber>1</MinorNumber>
    <!-- Default will be to get the SVN revision number as revision number -->
    <RevisionNumber>0</RevisionNumber>
  </PropertyGroup>

and I see a new file Projectname.AssemblyInfo.cs which contains now duplicated AssemblyVersionAttribute entries.

NullReference in PackageReferenceTransformation

Hi,

I'm encountering a NullReferenceException, I will try to debug where this is coming from.

Unhandled Exception: System.NullReferenceException: Object reference not set to
an instance of an object.
   at Project2015To2017.PackageReferenceTransformation.<>c__DisplayClass0_0.<Tra
nsformAsync>b__0(XElement x)
   at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
   at System.Linq.Enumerable.<ConcatIterator>d__58`1.MoveNext()
   at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
   at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
   at Project2015To2017.PackageReferenceTransformation.TransformAsync(XDocument
projectFile, DirectoryInfo projectFolder, Project definition)
   at Project2015To2017.Program.<>c__DisplayClass1_0.<Main>b__0(ITransformation
t)
   at System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext()
   at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
   at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
   at Project2015To2017.Program.Main(String[] args)

Edit:

The code is looking for a Version attribute, but it is an nested element.

PackageReferenceTransformation.cs:42

var existingPackageReferences = projectFile.Root.Elements(nsSys + "ItemGroup").Elements(nsSys + "PackageReference").Select(x => new PackageReference
{
    Id = x.Attribute("Include").Value,
    Version = x.Attribute("Version").Value,
    IsDevelopmentDependency = x.Element(nsSys + "PrivateAssets") != null
});
<PackageReference Include="Microsoft.Owin.Host.HttpListener" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <Version>3.1.0</Version>
</PackageReference>

ItemGroup with <Reference>'s should be deleted

I am not quite sure how it works but after migration I always have to manually delete node that starts from:
<ItemGroup> <Reference Include="AutoFixture, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b24654c590009d4f, processorArchitecture=MSIL"> <HintPath>..\..\packages\AutoFixture.4.0.0-rc1\lib\net452\AutoFixture.dll</HintPath> </Reference>

Can it be removed?

File inclusion checks get confused when only character case is different

When the case has changed between the original project and the included files, the converter gets confused as it is presumably doing a case sensitive check. Not sure how my projects ended up with different cases but they did.

Here's a simple sample I created and the messages generated

DemoApp.zip

File found which was not included, consider removing ####\DemoApp\program.cs.

File was included but is not on disk: ####\DemoApp\Program.cs.

NotSupportedException: Unable to parse output type

Run the tool (1.1) against VS-extensibility project, it fails:

Unhandled Exception: System.NotSupportedException: Unable to parse output type.
   at Project2015To2017.ProjectPropertiesTransformation.TransformAsync(XDocument projectFile, DirectoryInfo projectFolder, Project definition) in D:\Projects\CSProj2015To2017\Project2015To2017\ProjectPropertiesTransformation.cs:line 42
   at System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext()
   at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
   at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
   at Project2015To2017.Program.Main(String[] args) in D:\Projects\CSProj2015To2017\Project2015To2017\Program.cs:line 59

csproj

<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
  <PropertyGroup>
    <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">15.0</VisualStudioVersion>
    <OldToolsVersion>14.0</OldToolsVersion>
    <DslTargetsPath>..\SDK\v15.0\MSBuild\DSLTools</DslTargetsPath>
    <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
    <MinimumVisualStudioVersion>15.0</MinimumVisualStudioVersion>
  </PropertyGroup>
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <ProductVersion>9.0.30729</ProductVersion>
    <SchemaVersion>2.0</SchemaVersion>
    <ProjectGuid>{9F9AF5F0-C2CF-48B9-BF38-FEC89FDABA4A}</ProjectGuid>
    <OutputType>Library</OutputType>
    <AppDesignerFolder>Properties</AppDesignerFolder>
    <RootNamespace>Croc.XFW3.DomainModelDefinitionLanguage</RootNamespace>
    <AssemblyName>Croc.XFW3.DomainModelDefinitionLanguage.Dsl</AssemblyName>
    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
    <RestorePackages>true</RestorePackages>
    <IncludeDebugSymbolsInVSIXContainer>true</IncludeDebugSymbolsInVSIXContainer>
    <RestoreProjectStyle>PackageReference</RestoreProjectStyle>
    <RuntimeIdentifier>win7-x86</RuntimeIdentifier>
  </PropertyGroup>
...

Trimming PackageReferences

Thanks for an awesome tool! โค๏ธ

Since PackageReference will pull in transitive references (and packages.config doesn't), I find myself having to go through all the converted projects and manually trim the references to only the top-level packages.

It would be really awesome if this tool could do that for me ๐Ÿ˜„

I wonder if there's a NuGet API that would help out with resolving and giving back the only the top-level packages? @emgarten?

Create nuget package

This would be really useful for automatically processing a large number of solutions. It also opens up possibilities for bespoke pre and post-transforms and a simple method to specify options.

packages.config should be deleted

After converting project, packages.config still remains even though those references are now migrated to <PackageReference> elements.

The file is also specifically mentioned in the generated csproj:

<None Include="packages.config" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" />

Which it should not.

I recommend this file is deleted. Or at least renamed to .old.

Vbproj support?

Do you plan to support vb projects?
There should not be a lot of difference I guess..

Analyzers transformation not working as intended

<Analyzer>element might reference local "packages" directory:

<Analyzer Include="..\packages\AWSSDK.CloudWatch.3.3.2.2\analyzers\dotnet\cs\AWSSDK.CloudWatch.CodeAnalysis.dll" />

After conversion, this file is not found on disk (I'm not sure how this should be specified instead).

I found that when I install AWSSDK.CloudWatch using old project format, I get the <Analyzer> element.
But if I use the new csproj and install same package, the <Analyzer> element is not added.

Support for EmbeddedResource

After converting an old project containing embedded resources, the resources were no longer marked to be embedded.

ClassLibrary14.zip

I verified that the resources were embedded before and not after conversion using ILSpy.

Thanks for a great tool!

Older (VS2010) test project didn't get recognized as a test project

I have an old VS2010 era csproj test project, that didn't get recongized correctly as a test project. Here's an excerpt of the csproj file:

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <ProductVersion>
    </ProductVersion>
    <SchemaVersion>2.0</SchemaVersion>
    <ProjectGuid>{4F76FD48-0D14-4536-9699-7E528B63E6E4}</ProjectGuid>
    <OutputType>Library</OutputType>
    <AppDesignerFolder>Properties</AppDesignerFolder>
    <RootNamespace>FooTests</RootNamespace>
    <AssemblyName>Foo.Tests</AssemblyName>
    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
    <FileAlignment>512</FileAlignment>
    <ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
    <NuGetPackageImportStamp>
    </NuGetPackageImportStamp>
  </PropertyGroup>
</Project>

The tool is looking for the presence of a TestProjectType node in order to determine a test project, however in the example above, that node is not present and it is instead the ProjectTypeGuids containing 3AC096D0-A1C2-E12C-1390-A8335801FDAB that indicates it is a test project (ref.: https://www.codeproject.com/Reference/720512/List-of-Visual-Studio-Project-Type-GUIDs).

If the code were changes to check for either the presence of the above GUID or the TestProjectType node, it should fix this issue.

OutputType WinExe is not supported

Unhandled Exception: System.NotSupportedException: OutputType WinExe is not supported.
at Project2015To2017.ProjectPropertiesTransformation.ToApplicationType(String outputType)
at Project2015To2017.ProjectPropertiesTransformation.TransformAsync(XDocument projectFile, DirectoryInfo projectFolder, Project definition)
at Project2015To2017.Program.<>c__DisplayClass1_0.

b__0(ITransformation t)
at System.Linq.Enumerable.WhereSelectArrayIterator2.MoveNext() at System.Linq.Buffer1..ctor(IEnumerable1 source) at System.Linq.Enumerable.ToArray[TSource](IEnumerable1 source)
at Project2015To2017.Program.Main(String[] args)

PostBuildEvent is not migrated

We have some pre-build and post build events in some old projects.
These events are not migrated to new PostBuild target elements.

Change transform processing to be sequential and immutable

I'm working on this today, it should make future changes, fixes and tests much simpler.

Essentially it is making the Project the core entity which will be initially loaded from the legacy project rather than processing that in stages within each transform. The Project will contain the AssemblyInfo and Nuget info in the same way that it does at the moment. Each transform will take the Project and return a slightly transformed one which is then passed to the next transform.

Hope you are happy with it, I saw your comment on a recent fix you had to do, that it felt a bit hacky. Hopefully this change will make fixes easier and cleaner in future.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.