Migrate to csproj #703

Merged
merged 16 commits into from Feb 28, 2017

Projects

None yet

6 participants

@SteveSandersonMS
Contributor

This PR moves all the projects to .csproj and rebuilds the .sln to work with VS017RC. I'll squash all these commits before merging it into dev, but it's probably easier to review split up into all these commits.

There's still one more thing to be done - change the templates projects so they use RC4 tooling by default (currently they contain both project.json and .csproj files, and have a global.json that says to use preview2 tooling, because the project generator can emit projects of both types), but that won't affect the actual .csproj files which are the main aspect of the review I think.

@SteveSandersonMS SteveSandersonMS requested review from Eilon and natemcmaster Feb 22, 2017
+ <PackageTags>aspnetcore;aspnetcoremvc;nodeservices</PackageTags>
+ <RepositoryType>git</RepositoryType>
+ <RepositoryUrl>git://github.com/aspnet/javascriptservices</RepositoryUrl>
+ <NetStandardImplicitPackageVersion>1.6.1-*</NetStandardImplicitPackageVersion>
@SteveSandersonMS
SteveSandersonMS Feb 22, 2017 Contributor

I'm not sure why VS puts this NetStandardImplicitPackageVersion specification into all the projects. @natemcmaster - do you know if we need it?

@natemcmaster
natemcmaster Feb 22, 2017 Member

Depends. Should these packages target NETStandard.Library 1.6.0 or 1.6.1? The SDK defaults to 1.6.0. NetStandardImplicitPackageVersion will change that version.

@SteveSandersonMS
SteveSandersonMS Feb 23, 2017 Contributor

OK, thanks. It seems they are needed, because some of the dependency packages target 1.6.1, and if this one doesn't specify the same, it produces downgrade warnings. I'll move these lines to a common build props file.

@natemcmaster

Overall, there are a lot of lines of code (most likely generated by dotnet-migrate) that are redundant and can be removed.

I suggest putting all common properties -- such AssemblyOriginatorKeyFile, RepositoryUrl, etc -- into a single file the repo and using "Import" to pull them into individual projects. See https://github.com/aspnet/FileSystem/blob/dev/build/common.props for example.

Also, consider using the MSBuild properties <Company>, <Copyright>, and <Product>. The SDK can use these to auto-generate AssemblyInfo.cs and will put these in the nuspec of the generated nuget packages.

JavaScriptServices.sln
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
+ Debug|x64 = Debug|x64
@natemcmaster
natemcmaster Feb 22, 2017 Member

This was probably added automatically by VS or dotnet-migrate, but in general we don't need the x64 and x86 solution configurations for our projects. Consider removing these.

global.json
- "projects": ["src"],
- "sdk": { "version": "1.0.0-preview2-1-003177" }
-}
+ "projects": ["src"]
@natemcmaster
natemcmaster Feb 22, 2017 Member

Delete this whole file. The "projects" value is deprecated.

@@ -0,0 +1,45 @@
+<Project Sdk="Microsoft.NET.Sdk.Web">
+
+ <PropertyGroup>
@natemcmaster
natemcmaster Feb 22, 2017 Member

On all of your samples and template projects, consider adding <IsPackable>false</IsPackable>. This will allow you to execute dotnet pack on the solution and get packages for only those projects that should actually produce nuget packages.

+
+ <PropertyGroup>
+ <TargetFramework>netcoreapp1.1</TargetFramework>
+ <PreserveCompilationContext>true</PreserveCompilationContext>
@natemcmaster
natemcmaster Feb 22, 2017 Member

Nit: you can remove the following settings as they are the default value:

PreserveCompilationContext
AssemblyName
OutputType
RuntimeFrameworkVersion

+ </PropertyGroup>
+
+ <ItemGroup>
+ <Content Update="appsettings.json;ClientApp;node_modules;typings\**\*;Views\**\*;tsconfig.json;tsd.json;web.config;webpack.*.js;wwwroot\**\*">
@natemcmaster
natemcmaster Feb 22, 2017 Member

Test it, but I'm pretty sure this can be removed. Microsoft.Net.Sdk.Web will publish these files by default. If anything, you may want to exclude some of these from publish, such as node_moduels, tsconfig, webpack, etc.

+
+ <PropertyGroup>
+ <TargetFramework>netcoreapp1.0</TargetFramework>
+ <PreserveCompilationContext>true</PreserveCompilationContext>
@natemcmaster
natemcmaster Feb 22, 2017 Member

Nit: likewise here, remove the default values.

(Repeat same comment for most of the projects below)

+ <AssemblyName>NodeServicesExamples</AssemblyName>
+ <OutputType>Exe</OutputType>
+ <PackageId>NodeServicesExamples</PackageId>
+ <RuntimeFrameworkVersion>1.1.0</RuntimeFrameworkVersion>
@natemcmaster
natemcmaster Feb 22, 2017 Member

This is an unsupported mix of runtime version and TFM. Change the framework to netcoreapp1.1 and remove this property.

This is true of several other projects in the PR.

+ </ItemGroup>
+
+ <ItemGroup>
+ <PackageReference Include="Microsoft.AspNetCore.Diagnostics" Version="1.1.0" />
@natemcmaster
natemcmaster Feb 22, 2017 Member

Consider using Microsoft.AspNetCore metapackage instead. It would trim this section to 3 dependencies:

Microsoft.AspNetCore
Microsoft.AspNetCore.Mvc
Microsoft.Extensions.Logging.Debug
@SteveSandersonMS
SteveSandersonMS Feb 23, 2017 Contributor

Done. Also needed Microsoft.AspNetCore.StaticFiles.

@SteveSandersonMS
SteveSandersonMS Feb 23, 2017 Contributor

Also updated various other projects in the same way

+
+ <PropertyGroup>
+ <Description>Helpers for building Angular 2 applications on ASP.NET Core.</Description>
+ <VersionPrefix>1.1.0-beta2</VersionPrefix>
@natemcmaster
natemcmaster Feb 22, 2017 Member

The more conventional way to express this is

<VersionPrefix>1.1.0</VersionPrefix>
<VersionSuffix>beta2</VersionSuffix>
+ <RepositoryType>git</RepositoryType>
+ <RepositoryUrl>git://github.com/aspnet/javascriptservices</RepositoryUrl>
+ <NetStandardImplicitPackageVersion>1.6.1-*</NetStandardImplicitPackageVersion>
+ <GenerateNeutralResourcesLanguageAttribute>false</GenerateNeutralResourcesLanguageAttribute>
@natemcmaster
natemcmaster Feb 22, 2017 Member

Consider removing AssemblyInfo.cs and letting the SDK generate these assembly attributes.

+ <PackageReference Include="Microsoft.AspNetCore.Mvc.TagHelpers" Version="1.1.0" />
+ </ItemGroup>
+
+ <ItemGroup Condition=" '$(TargetFramework)' == 'net451' ">
@natemcmaster
natemcmaster Feb 22, 2017 Member

This whole ItemGroup is usually redundant because your app will reference NETStandard.Library. It can be removed.

+ <PackageTags>aspnetcore;aspnetcoremvc;nodeservices</PackageTags>
+ <RepositoryType>git</RepositoryType>
+ <RepositoryUrl>git://github.com/aspnet/javascriptservices</RepositoryUrl>
+ <NetStandardImplicitPackageVersion>1.6.1-*</NetStandardImplicitPackageVersion>
@natemcmaster
natemcmaster Feb 22, 2017 Member

Depends. Should these packages target NETStandard.Library 1.6.0 or 1.6.1? The SDK defaults to 1.6.0. NetStandardImplicitPackageVersion will change that version.

+ </PropertyGroup>
+
+ <ItemGroup>
+ <EmbeddedResource Include="Content\**\*" Exclude="bin\**;obj\**;**\*.xproj;packages\**;@(EmbeddedResource)" />
@natemcmaster
natemcmaster Feb 22, 2017 Member

Pretty sure you can remove this line. It doesn't appear that this project would embed anything in these folders by default.

@SteveSandersonMS
SteveSandersonMS Feb 23, 2017 Contributor

It does embed resources from the Content folder (some .js files built from the TypeScript source). Let me know if you still think this is wrong.

@natemcmaster
natemcmaster Feb 23, 2017 Member

Oh, didn't realize embedded js was intended. You can probably remove the "Exclude" value since it Content\**\* doesn't match any of the exclude patterns. Otherwise this looks good.

@SteveSandersonMS
SteveSandersonMS Feb 24, 2017 Contributor

Yes, you're right - the Exclude values can be removed. Done.

+
+ <PropertyGroup>
+ <Description>Invoke Node.js modules at runtime in ASP.NET Core applications.</Description>
+ <VersionPrefix>1.1.1-alpha</VersionPrefix>
@natemcmaster
natemcmaster Feb 22, 2017 Member

Consider making all packages in the repo the same version.

@Eilon
Eilon Feb 23, 2017 Member

Some of these projects are RTM and some are not, so they probably don't all version the same.

@SteveSandersonMS
SteveSandersonMS Feb 23, 2017 Contributor

Leaving as-is

+ <PackageId>Microsoft.AspNetCore.NodeServices</PackageId>
+ <PackageTags>aspnetcore;aspnetcoremvc;nodeservices</PackageTags>
+ <RepositoryType>git</RepositoryType>
+ <RepositoryUrl>git://github.com/aspnet/javascriptservices</RepositoryUrl>
@natemcmaster
natemcmaster Feb 22, 2017 Member

I suggest changing this to https:// instead. git:// isn't browser-friendly.

+ </PropertyGroup>
+
+ <ItemGroup>
+ <EmbeddedResource Include="Content\**\*" Exclude="bin\**;obj\**;**\*.xproj;packages\**;@(EmbeddedResource)" />
@natemcmaster
natemcmaster Feb 22, 2017 Member

Likewise here. These globs are probably not required.

@SteveSandersonMS
SteveSandersonMS Feb 23, 2017 Contributor

There are files to be embedded from Content, so leaving this as-is, but please let me know if you still think this is wrong.

@SteveSandersonMS
SteveSandersonMS Feb 24, 2017 Contributor

Removed the Exclude part

+ <OutputType>Exe</OutputType>
+ <PackageId>WebApplicationBasic</PackageId>
+ <RuntimeFrameworkVersion>1.1.0</RuntimeFrameworkVersion>
+ <PackageTargetFallback>$(PackageTargetFallback);dotnet5.6;portable-net45+win8</PackageTargetFallback>
@natemcmaster
natemcmaster Feb 22, 2017 Member

Can these be dropped? I didn't see anything in the list of dependencies that would require these fallback frameworks anymore.

@SteveSandersonMS
SteveSandersonMS Feb 23, 2017 Contributor

I don't know why the migration util put those there. I don't really even know what effect they would ever have. Removing.

+
+ <ItemGroup>
+ <Compile Remove="node_modules\**\*" />
+ <Content Update="appsettings.json;Views\**\*;web.config;wwwroot\**\*">
@natemcmaster
natemcmaster Feb 22, 2017 Member

This can be removed. It is already the default for Sdk.Web projects.

@Eilon

+1 to what @natemcmaster said, will look again once his comments are addressed.

@MarkPieszak
Contributor

With these updates everything is now only VS2017+ only, correct? @SteveSandersonMS @natemcmaster

@natemcmaster
Member
natemcmaster commented Feb 23, 2017 edited

@MarkPieszak it means building this repo requires VS 2017, VS Code + C# 1.7, or .NET Core CLI 1.0.0-rc4

JavaScriptServices.sln
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{BDE761D9-8E1C-4FB1-BB86-110393C59176}"
+EndProject
+Project("{E24C65DC-7377-472B-9ABA-BC803B73C61A}") = "test", "test\", "{A01B46C2-53D8-499D-8CDE-68E3E7B52804}"
+ ProjectSection(WebsiteProperties) = preProject
@davidfowl
davidfowl Feb 23, 2017 Member

wtf is this 😄

@SteveSandersonMS
SteveSandersonMS Feb 23, 2017 edited Contributor

Yes indeed. When are we getting a project type that means "just show me the files and don't try to build anything"?

@natemcmaster
natemcmaster Feb 23, 2017 Member

I've never seen this section either. Is this a carry-over from ASP.NET 4?

@SteveSandersonMS
SteveSandersonMS Feb 24, 2017 Contributor

@natemcmaster It's a "Web site" project (as in, just a folder full of files, without any .NET). It's pretty nasty, but does VS2017 have any better way of working with front-end resources? It no longer seems to have the "TypeScript" project type. People have been talking about having an "html" project type forever, but I still don't see anything resembling that in VS2017.

@natemcmaster
natemcmaster Feb 24, 2017 Member

Ah, thanks for clarifying. I'm not sure if VS 2017 has these project types, and I haven't run into this requirement yet. But hey, if it makes it easier to work with files in VS 2017, go for it. It shouldn't affect compilation.

@SteveSandersonMS
Contributor

Thanks @natemcmaster for the feedback. I learned a lot! You're right that most of this stuff was produced by the migration tool, but it's nice to get it into a cleaner state.

src/common.props
+ <RepositoryType>git</RepositoryType>
+ <RepositoryUrl>https://github.com/aspnet/javascriptservices</RepositoryUrl>
+
+ <GenerateNeutralResourcesLanguageAttribute>true</GenerateNeutralResourcesLanguageAttribute>
@natemcmaster
natemcmaster Feb 23, 2017 Member

These Generate*Attribute settings default to true so you can remove them, but you still need to set the values for the generate attributes by setting properties for <Company> and etc.

These are the default proeprties we set in all of our other aspnet projects.

    <Product>Microsoft ASP.NET Core</Product>
    <NeutralLanguage>en-US</NeutralLanguage>
    <Company>Microsoft Corporation.</Company>
    <Authors>Microsoft</Authors>
    <Copyright>© Microsoft Corporation. All rights reserved.</Copyright>
    <ProjectUrl>https://asp.net</ProjectUrl>
    <RequireLicenseAcceptance>true</RequireLicenseAcceptance>
    <Serviceable>true</Serviceable>

To clarify something...you don't see this in the build/common.props files in other github.com/aspnet projects, but instead you will see a PackageReference to "Internal.AspNetCore.Sdk". (see below).

@SteveSandersonMS
SteveSandersonMS Feb 24, 2017 Contributor

Thanks for the pointers. I've added a reference to Internal.AspNetCore.Sdk (in common.props) and moved a few files around to make it pretty much the same as the other ASP.NET Core projects.

@natemcmaster
Member

Consider also adding a PackageReference to Internal.AspNet.Sdk to the projects in src/*.csproj that produce official packages. Internal.AspNet.Sdk is defined in our build tools repo and is how we set these common properties and build targets. We did this via package to make it easier to put common MSBuild code in one place instead of duplicating across 50-ish repos.

Internal.AspNetCore.Sdk extends the build to generate AssemblyMetadata("CommitHash", (git commit)) and AssemblyMetadata("Serviceable", "True"). These things aren't provided by the default targets from Microsoft.NET.Sdk.

-using System.Resources;
-using System.Runtime.CompilerServices;
-
-[assembly: AssemblyMetadata("Serviceable", "True")]
@natemcmaster
natemcmaster Feb 23, 2017 Member

Unless you add Internal.AspNetCore.Sdk, you'll need to keep this one. It's not generated by Microsoft.NET.Sdk.

cref https://github.com/aspnet/BuildTools/blob/e4be7e105de6c3bf2e882bb76f3565305ca5a46d/src/Internal.AspNetCore.Sdk/build/GenerateAssemblyInfo.targets

@SteveSandersonMS
SteveSandersonMS Feb 24, 2017 edited Contributor

Done (by referencing Internal.AspNetCore.Sdk)

SteveSandersonMS added some commits Feb 24, 2017
@SteveSandersonMS SteveSandersonMS Make HMR dramatically faster if you're using IIS Express
Doesn't affect other scenarios (e.g., directly using Kestrel, which was
already this fast).
f97cb73
@SteveSandersonMS SteveSandersonMS Migrate NodeServices and NodeServices.Sockets to csproj 1541a2b
@SteveSandersonMS SteveSandersonMS Migrate SpaServices/AngularServices/ReactServices projects to csproj b4e7d7b
@SteveSandersonMS SteveSandersonMS Add some solution items 5a0cf0e
@SteveSandersonMS SteveSandersonMS Migrate LatencyTest/Webpack/NodeServicesExamples samples to csproj 4e77054
@SteveSandersonMS SteveSandersonMS Migrate Angular and React samples to csproj 9927664
@SteveSandersonMS SteveSandersonMS Add SPA templates to VS .sln (also renaming Aurelia project to Aureli…
…aSpa for consistency)
bc66842
@SteveSandersonMS SteveSandersonMS Migrate WebApplicationBasic template to csproj 765586b
@SteveSandersonMS SteveSandersonMS Add template-builder and test dirs to VS solution as "web sites" unti…
…l there's a better pure front-end project type
f50a015
@SteveSandersonMS SteveSandersonMS Add missing hint in solution file f4e151a
@SteveSandersonMS SteveSandersonMS Make sure VS doesn't litter the disk with irrelevant/harmful .js file…
…s whenever it sees .ts files
7c95f7c
@SteveSandersonMS SteveSandersonMS Respond to csproj migration code review feedback 2c780a4
@SteveSandersonMS SteveSandersonMS Add references to Internal.AspNetCore.Sdk. Move build files into "bui…
…ld\" dir for consistency.
f125d3f
@SteveSandersonMS SteveSandersonMS Remove unnecessary `Exclude` attributes as per CR feedback 45a6460
@SteveSandersonMS SteveSandersonMS Only reference released versions of ASP.NET Core packages
0429fbf
@Eilon
Eilon approved these changes Feb 24, 2017 View changes

Looks great, period!

+ <Import Project="..\build\common.props" />
+
+ <PropertyGroup>
+ <Description>Socket-based RPC for Microsoft.AspNetCore.NodeServices</Description>
@Eilon
Eilon Feb 24, 2017 Member

End sentence with a period

.

+ <Import Project="..\build\common.props" />
+
+ <PropertyGroup>
+ <Description>Helpers for building single-page applications on ASP.NET MVC Core</Description>
@Eilon
Eilon Feb 24, 2017 Member

Period.

@Eilon
Member
Eilon commented Feb 24, 2017

Oh and we should figure out why the CLA bot doesn't like you...

@SteveSandersonMS SteveSandersonMS End package descriptions with periods
d0c3e81
@SteveSandersonMS SteveSandersonMS merged commit a79bc75 into dev Feb 28, 2017

0 of 2 checks passed

continuous-integration/appveyor/branch Waiting for AppVeyor build to complete
Details
continuous-integration/appveyor/pr Waiting for AppVeyor build to complete
Details
@SteveSandersonMS SteveSandersonMS deleted the csproj-migration branch Feb 28, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment