try-convert icon indicating copy to clipboard operation
try-convert copied to clipboard

Feature request: convert proj files

Open MaherJendoubi opened this issue 3 years ago • 8 comments

It will be useful if this tool could convert proj files referenced in the csproj file:

https://github.com/ClearCanvas/ClearCanvas/blob/master/Executable/ClearCanvas.Executable.csproj#L128

https://github.com/ClearCanvas/ClearCanvas/blob/master/Executable/PostBuild_dist.proj

MaherJendoubi avatar Dec 01 '20 19:12 MaherJendoubi

What should it convert these into? Today we bail out when we encounter custom msbuild logic like this because we cannot know what it is supposed to do unless we run the build script and analyze it. Supposing we do that (which is a lot of work to suppose) what transformation do you expect here?

jmarolf avatar Dec 01 '20 22:12 jmarolf

I totally understand that. My request is to use the same xml schema version. When try-convert transforms the csproj to a modern xml msbuild version, the proj file remains the same with such an old schema version : https://github.com/ClearCanvas/ClearCanvas/blob/master/Executable/PostBuild_dist.proj#L1

MaherJendoubi avatar Dec 01 '20 22:12 MaherJendoubi

got it, we could give you a "Just convert this project, even if there are custom imports and just go with it" (which is what I believe you are asking for). If we added a flag for that I would not want it to be on by default as there are all sorts of trouble people could get into if their build doesn't work the way they expect.

In general, the first duty of this tool is to not change how you build works. Today, if we can't do that we choose to do nothing. I am ok with allowing people to do more dangerous transformations but it may do more harm than good. A truly custom build is just going to get wrecked by this tool and it would be less work to do the port by hand in most cases.

jmarolf avatar Dec 01 '20 22:12 jmarolf

Let me rephrase/elaborate my need. What I am asking is to homogenize the csproj and proj files when try-converting them. Why the csproj file becomes something like <Project Sdk="Microsoft.NET.Sdk.Web"> or <Project Sdk="Microsoft.NET.Sdk"> but proj file remaines <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> ?

MaherJendoubi avatar Dec 01 '20 22:12 MaherJendoubi

@KirillOsenkov what do you think about this feature?

MaherJendoubi avatar Dec 01 '20 23:12 MaherJendoubi

Why the csproj file becomes something like <Project Sdk="Microsoft.NET.Sdk.Web"> or <Project Sdk="Microsoft.NET.Sdk"> but proj file remaines <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> ?

<Project Sdk="Microsoft.NET.Sdk.Web"> and <Project Sdk="Microsoft.NET.Sdk"> means that a specific set of props and targets files are implicitly imported

Specifcally

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net5.0</TargetFramework>
  </PropertyGroup>

</Project>

Is equivalent to this:

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <Import Project="C:\Program Files\dotnet\sdk\5.0.100\Sdks\Microsoft.NET.Sdk\Sdk\Sdk.props"  />  

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net5.0</TargetFramework>
  </PropertyGroup>

  <Import Project="C:\Program Files\dotnet\sdk\5.0.100\Sdks\Microsoft.NET.Sdk\Sdk\Sdk.targets"  />
</Project>

If we converted your proj file to use Sdk= it would include those props and targets and be opted into a lot of implicit behavior. Is that the right thing for your project? Perhaps but I do not know. It Just as easily could be adding a lot of implicit behavior that you do not want and creating more work for you.

jmarolf avatar Dec 01 '20 23:12 jmarolf

I guess it's safe to strip xmlns="..." but I doubt it's feasible to do more than that IMHO

KirillOsenkov avatar Dec 01 '20 23:12 KirillOsenkov

Thank you both for your reply. I guess it is also doable to combine/merge the csproj and the proj files.

MaherJendoubi avatar Dec 01 '20 23:12 MaherJendoubi