Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is Visual Studio 2017 new .csproj relevant to non .net core projects

I'm a bit confused. I have the new version of Visual Studio 2017. And have converted my class projects (.net full 4.5) to the new .csproj project format. Then I tried to run live tests on those projects, but VS now informs me that live testing is not supported on .net core projects jet.

So:

  1. Are those projects now .Net Core projects?
  2. If Yes, can I use the new .csproj project file for the old good .Net Full 4.x
  3. I am planning to deploy my application as WebApi services to a windows server only, and I'm planning to use NHibernate ORM, so movig to .net Core is excluded, are there any benefit of using this new .csproj format for my case?
  4. Can I use the new .csproj format and keep using non .Net Core compatible libraries like NHibernate?

Thanks

like image 254
Luka Avatar asked Mar 10 '17 20:03

Luka


People also ask

What is Csproj file used for?

CSPROJ files define a project's content, platform requirements, versioning information, and web server or database server settings. They also list the files that are part of the project.

What is SDK style project?

Each project SDK is a set of MSBuild targets and associated tasks that are responsible for compiling, packing, and publishing code. A project that references a project SDK is sometimes referred to as an SDK-style project.

Where is Csproj file 2017?

What I often in Visual Studio 2017 RC3 to edit the csproj file, is: Right click on the project title in the Solution Explorer window. Select the option "Edit [project name]. csproj" to open the csproj file in the code editor window.


1 Answers

I like the new format for .net 4.0 projects, it's way easier not having to worry about including files to your project also having less files to deal with nuget is nice as well.

You can start out with a csproj as simple as this

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

  <PropertyGroup>
    <TargetFramework>net40</TargetFramework>
  </PropertyGroup>

</Project>

And then use visual studio to add back in your dependencies, move the meta data to the packages tab and remove AssemblyInfo.cs, and then customize anything you had custom (hint sometimes excluding and re-including files can help to get the default behavior if you have something strange e.g. T4 templates). It will be a much cleaner file and way easier to update to .netstandard in the future (or even multitarget).

Here is an example of an opensource project of mine using multi-target and some T4 templates this is the full file and there are like 40 C# files automatically included in the project because they are in the directory:

<Project Sdk="Microsoft.NET.Sdk">
    <PropertyGroup>
        <TargetFrameworks>netstandard1.5;net40</TargetFrameworks>
        <Description>(pronounced dyna-mighty) flexes DLR muscle to do meta-mazing things in .net</Description>
        <Company>Ekon Benefits</Company>
        <Authors/>
        <Copyright>Copyright 2017 Ekon Benefits</Copyright>
        <AssemblyVersion>1.5.0.0</AssemblyVersion>
        <FileVersion>1.5.0.0</FileVersion>
        <PackageProjectUrl>https://github.com/ekonbenefits/dynamitey</PackageProjectUrl>
        <PackageLicenseUrl>http://www.apache.org/licenses/LICENSE-2.0</PackageLicenseUrl>
        <PackageTags>dynamic metaprogramming dlr reflection currying tuples expando latetypes</PackageTags>
        <IncludeSymbols>True</IncludeSymbols>
        <IncludeSource>True</IncludeSource>
        <GeneratePackageOnBuild>True</GeneratePackageOnBuild>
        <PackageRequireLicenseAcceptance>True</PackageRequireLicenseAcceptance>
        <SignAssembly>True</SignAssembly>
        <AssemblyOriginatorKeyFile>sn.snk</AssemblyOriginatorKeyFile>
        <DelaySign>False</DelaySign>
        <Version>1.5.0</Version>
    </PropertyGroup>
    <ItemGroup Condition="'$(TargetFramework)'!='net40'">
        <PackageReference Include="Microsoft.CSharp" Version="4.3.0"/>
        <PackageReference Include="System.ComponentModel" Version="4.3.0"/>
    </ItemGroup>
    <ItemGroup Condition="'$(TargetFramework)'=='net40'">
        <Reference Include="Microsoft.CSharp"/>
    </ItemGroup>
    <ItemGroup>
        <None Update="InlineLambdas.tt">
            <Generator>TextTemplatingFileGenerator</Generator>
            <LastGenOutput>InlineLambdas.cs</LastGenOutput>
        </None>
        <None Update="ThisFunctions.tt">
            <Generator>TextTemplatingFileGenerator</Generator>
            <LastGenOutput>ThisFunctions.cs</LastGenOutput>
        </None>
    </ItemGroup>
    <ItemGroup>
        <Compile Update="InlineLambdas.cs">
            <DesignTime>True</DesignTime>
            <AutoGen>True</AutoGen>
            <DependentUpon>InlineLambdas.tt</DependentUpon>
        </Compile>
        <Compile Update="ThisFunctions.cs">
            <DesignTime>True</DesignTime>
            <AutoGen>True</AutoGen>
            <DependentUpon>ThisFunctions.tt</DependentUpon>
        </Compile>
    </ItemGroup>
</Project>
like image 111
jbtule Avatar answered Nov 12 '22 03:11

jbtule