codeformatter icon indicating copy to clipboard operation
codeformatter copied to clipboard

Support formatting ASP.NET vNext projects

Open conniey opened this issue 10 years ago • 8 comments

I have an library that is written in C#, but I converted it to a .kproj (ASP.NET vNext library) so that my ASP.NET vNext website could also use its logic.

CodeFormatter skips over this project and doesn't format it. so I have to manually create a .csproj, add the .cs files, and run the formatter tool again.

.kproj Samples

conniey avatar Mar 02 '15 23:03 conniey

@jasonmalinowski is there any way to load up ASP.Net vNext projects in Roslyn today? Right now the CodeFormatter just uses a MSBuildWorkspace. If there is an easy way to load this project type I'm sure it wouldn't take much work to get the code formatter to support it.

jaredpar avatar Mar 03 '15 06:03 jaredpar

It's possible but not very nice right now. We're working on an API that will make this less sucky.

davidfowl avatar Mar 03 '15 06:03 davidfowl

@davidfowl is there a GitHub issue I can track for this API? Once it's available I'd like to try it out here.

jaredpar avatar Mar 03 '15 06:03 jaredpar

Not really, we're mostly layering things differently (some in NuGet, some in XRE) to make this possible. I'll update this thread when we get closer to having something useful.

davidfowl avatar Mar 03 '15 06:03 davidfowl

@conniey Please also note that you don't have to convert your existing library project to a kproj to be able to reference it from your ASP.NET 5 app as long as you are ok with the app running on the full .NET Framework. You can reference csproj based projects from an ASP.NET 5 app. You would need to port your existing project only if you wanted to be able to run on .NET Core.

danroth27 avatar Mar 03 '15 20:03 danroth27

@conniey @danroth27 We also plan on adding ASP.NET 5 as a target from a Portable Library so you wont need to have a seperate project file and multiple builds if you want to have you're shared logic applicable to multiple places.

Petermarcu avatar Mar 04 '15 00:03 Petermarcu

@danroth27 The application that uses the library, I want to run on .NET Core. :) Thanks for the tip though.

conniey avatar Mar 09 '15 04:03 conniey

This issue also occurs with .xproj files. Here is my workaround:

  1. Add CodeFormatterWorkaround.csproj in your the directory.
  2. Then run codeformatter .\CodeFormatterWorkaround.csproj

This recursively formats all *.cs files without needing to specify them individually. Hooray!

CodeFormatterWorkaround.csproj contains only the following:

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <ItemGroup>
    <Compile Include="*.cs" />
    <Compile Include=".\**\*.cs" />
  </ItemGroup>
  <Target Name="Compile">
    <Csc Sources="@(Compile)"/>  
  </Target>
</Project>

See also: http://stackoverflow.com/questions/6914046/can-ms-build-include-all-library-project-code-files-without-specifying-them-indi

shaunluttin avatar Jun 09 '15 03:06 shaunluttin