Msbuild: Using the new .Csproj without .Net core

Created on 10 Feb 2017  路  17Comments  路  Source: dotnet/msbuild

Apologies if this is the wrong repository.

Is it possible to use the new .Csproj format without targeting .Net core? I.e. targeting .NET 4.5.x or 4.6.x?

Most helpful comment

We wanted to unify csproj tooling across all the .NET stacks this release, but it turned into a fairly large undertaking (who knew 15 years of tooling would be hard to replace!). I don't have timelines when we'll do it, and what order we'll do it in, but I'm confident that we'll be able to move the majority of projects over to using the new project system (http://github.com/dotnet/roslyn-project-system), and then a significant portion of those over to the SDK-based format in future releases.

All 17 comments

Yes, the SDK tooling works for .NET Framework without explicitly targeting .NET Core. However, there are caveats. We've focused this release entirely about making just compile of Console Apps, Libraries and ASP.NET _Core_ on NET Framework work. You cannot use the tooling build/use .NET Framework projects that contain Windows Forms, WPF, Workflow, ASP.NET Web Forms, etc.

Paging @onovotny, who does this a bit and can probably point to some guidance he's written.

Oh gotcha. Thanks for the quick response. That's too bad about the ASP.net web forms. Is supporting these other projects on the roadmap after the release of VS 2017, or are there other more urgent priorities?

We wanted to unify csproj tooling across all the .NET stacks this release, but it turned into a fairly large undertaking (who knew 15 years of tooling would be hard to replace!). I don't have timelines when we'll do it, and what order we'll do it in, but I'm confident that we'll be able to move the majority of projects over to using the new project system (http://github.com/dotnet/roslyn-project-system), and then a significant portion of those over to the SDK-based format in future releases.

OK, thanks for the information that you're able to provide. I haven't heard of this SDK-based format. Do you have a link or keywords for where I can learn more? Google doesn't turn up anything.

Is it any plans to simplyfi vcxproj to in the future?

We doc'd some of it here: https://docs.microsoft.com/en-us/dotnet/articles/core/preview3/tools/csproj, you can see an example template here: https://github.com/dotnet/sdk/blob/master/src/Templates/ProjectTemplates/CSharp/.NETCore/CSharpConsoleApplication/ProjectTemplate.csproj. That "Sdk" attribute basically auto-imports a props at the top of the project and a targets at the bottom.

@magol To be honest, no plans as of yet. The C++ team are aware of the work we're doing, and once we've landed .NET Core scenarios lots of the new features we've added will just work for them, but I cannot promise anything.

@davkean Is it any list of the new features? For example, what new features do you think will be usable in vcxproj?
Do the c++ team have any github repository or mail list?

An example of a couple of the new features that vcxproj might be able to benefit from, is auto-reload (ie project file changes on disk, we pick up the changes automatically), or project file editing while the project is open. C++ team does not have a repo or a mailing list (that I'm aware of), Report a Problem/Suggestion from VS would be away to give feedback to them.

@davkean Great improvements. But i can not expect any simplifications of the xml in the vcxproj file?

@magol I can only speak for things that I work on, I don't work on C++ - so can't talk about any format improvements that they may or may not.

You can build any project type with the SDK style builds. The main trick is to set the LanaguageTargets to the correct project specific targets for the type of project you want to build. I talk about how it all works here: https://oren.codes/2017/01/04/multi-targeting-the-world-a-single-project-to-rule-them-all/

That said, there are some additional things you'll need to add for certain project types that need additional actions - metadata for specific things like WPF pages, etc.

This issue is working on what's needed for WPF: https://github.com/dotnet/roslyn-project-system/issues/1467. The specific globs to add are here: https://github.com/Microsoft/VSProjectSystem/issues/169

Should look something like:

<Compile Update="**\*.xaml.cs">
        <DependentUpon>%(Filename)</DependentUpon>      
        <SubType>Code</SubType>
</Compile>

<Page Include="**\*.xaml">
        <Generator>MSBuild:Compile</Generator>
        <SubType>Designer</SubType>      
</Page>

@davkean is there any roadmap or GitHub issue for tracking progress of the "new csproj format for all project types"?

https://github.com/dotnet/project-system/blob/master/docs/repo/roadmap.md - make note there is no dates associated with the "16.0" milestone that its associated with.

Anyone got this working? I'm able to compile it but I lost intellisense in VS 2017.

This is my csproj:

```xml


$(MSBuildExtensionsPath)\$(VisualStudioVersion)\Bin\Microsoft.CSharp.targets
winexe
net462
Full
res\ico\icon.ico
winexe


15.0
$(MSBuildExtensionsPath32)\Microsoft\VisualStudiov$(VisualStudioVersion)
True
false



<!-- XAML elements -->
<Page Include="**\*.xaml" SubType="Designer" Generator="MSBuild:UpdateDesignTimeXaml" Exclude="App.xaml" />
<Compile Update="**\*.xaml.cs" SubType="Designer" DependentUpon="%(Filename)" />
<Compile Include="$(IntermediateOutputPath)**\*.g.cs" Visible="false" />
<None Include="$(ProjectDir)obj" Visible="false" />

<!-- Resources -->
<EmbeddedResource Update="Properties\Resources.resx" Generator="ResXFileCodeGenerator" LastGenOutput="Resources.Designer.cs" />
<Compile Update="Properties\Resources.Designer.cs" AutoGen="True" DependentUpon="Resources.resx" DesignTime="True" />

<!-- Settings -->
<None Update="Properties\Settings.settings" Generator="SettingsSingleFileGenerator" LastGenOutput="Settings.Designer.cs" />
<Compile Update="Properties\Settings.Designer.cs" AutoGen="True" DependentUpon="Settings.settings" />

<None Update="App.config">
  <TransformOnBuild>true</TransformOnBuild>
</None>
<None Update="App.Debug.config">
  <IsTransformFile>True</IsTransformFile>
</None>
<None Update="App.Release.config">
  <IsTransformFile>True</IsTransformFile>
</None>












$(AssemblySearchPaths);{GAC}


@onovotny thanks for the great information dump on how to migrate existing WPF projects...

I was wondering if you could help in porting Windows Forms project to the new csproj.

I assume that except for <LanguageTargets> I also need to find the names of the generators for windows form classes... right?

In other words...
In "old style" csproj I have:

    <Compile Include="AmazingForm.cs">
      <SubType>Form</SubType>
    </Compile>

I'm assuming the .cs files that are form based need to have a special generator in order for them to compile....

What would that Generator be?

Anyone aware of how to include Telerik reports in the new project template?

Was this page helpful?
0 / 5 - 0 ratings