Skip to content
This repository has been archived by the owner on Dec 14, 2018. It is now read-only.

Convert MVC to CSproj. #5749

Closed
wants to merge 5 commits into from
Closed

Convert MVC to CSproj. #5749

wants to merge 5 commits into from

Conversation

NTaylorMullen
Copy link
Contributor

  • Allow >= RC3 CLI's to build and run MVC.
  • Added extra sln's so they could be opened in VS. Currently VS' project system can't currently handle Mvc.sln.
  • Worked around several dotnet migration issues. They are listed in the re-attempted migration section here: [Tracker] MSBuild conversion issues #5482
  • One large feature bit that couldn't be worked around was the functional tests running on desktop; it represented several known vstest issues. Removed desktop running of functional tests.
  • Skipped an ActionContextAccessor test due to a vstest appdomain problem.

Note: You cannot use the Test Explorer in VS for this migration pass. Working with VS folks to figure that out. Wont merge until that's resolved.

@natemcmaster
Copy link
Contributor

this might take me a while to review. I'll take a look tomorrow.
image
image

makefile.shade Outdated
k-standard-goals

#restore-nuget-packages target='initialize'
exec program='${Path.Combine(Directory.GetCurrentDirectory(), ".build", "nuget.exe")}' commandline='restore Mvc.sln'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The equivalent code in Razor was to support building the vsix, so I don't think this is needed here. If you're trying to "select" the sln, you need to use dotnet restore

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 remove if possible


<PropertyGroup>
<TargetFrameworks>net451;netcoreapp1.1</TargetFrameworks>
<RuntimeIdentifiers>win7-x64;win7-x86;osx.10.10-x64;osx.10.11-x64;ubuntu.14.04-x64;ubuntu.16.04-x64;centos.7-x64;rhel.7.2-x64;debian.8-x64;fedora.23-x64;opensuse.13.2-x64</RuntimeIdentifiers>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can remove.

</PropertyGroup>

<ItemGroup>
<Content Update="Views\**\*;web.config;wwwroot">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<Content Update="Views\**\*;web.config;wwwroot" CopyToPublishDirectory="PreserveNewest" />

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this whole line can be removed. IIUC this is handled by default by Microsoft.NET.Sdk.Web

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It knows about the Views folder?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Talked offline, it knows about *.cshtml


<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Diagnostics" Version="1.2.0-*" />
<PackageReference Include="Microsoft.AspNetCore.Razor" Version="1.2.0-*" />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this + the next one.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do, why was it added in the project.json world?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No idea. Maybe a remnant from when we did not have Microsoft.AspNet.Mvc and had individual projects?


<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Routing.Abstractions" Version="1.2.0-*" />
<PackageReference Include="Microsoft.Extensions.ClosedGenericMatcher.Sources" Version="1.2.0-*">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<PackageReference Include="Microsoft.Extensions.ClosedGenericMatcher.Sources" Version="1.2.0-*" PrivateAssets="All" /> and similarly below.

<PropertyGroup>
<TargetFrameworks>net451;netcoreapp1.1</TargetFrameworks>
<RuntimeIdentifiers>win7-x64;win7-x86;osx.10.10-x64;osx.10.11-x64;ubuntu.14.04-x64;ubuntu.16.04-x64;centos.7-x64;rhel.7.2-x64;debian.8-x64;fedora.23-x64;opensuse.13.2-x64</RuntimeIdentifiers>
<RuntimeIdentifier Condition=" '$(TargetFramework)' == 'net451' ">win7-x86</RuntimeIdentifier>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

x64?

</PropertyGroup>

<ItemGroup>
<Content Update="web.config">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could remove these. We don't actually do any IIS publishing tests so this isn't super necessary. I'll leave it up to you

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can remove it be Microsoft.NET.Sdk.Web finds the web.config file by default.

<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="1.2.0-*" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net451' ">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove

<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="1.2.0-*" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net451' ">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove x n

</PropertyGroup>

<ItemGroup>
<EmbeddedResource Include="EmbeddedResources\**" Exclude="bin\**;obj\**;**\*.xproj;packages\**;@(EmbeddedResource)" />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Think you can remove the the Exclude node.

deploy: off
# Required for dotnet-test to work
os: Visual Studio 2015
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Visual Studio 2017 RC

makefile.shade Outdated
k-standard-goals

#restore-nuget-packages target='initialize'
exec program='${Path.Combine(Directory.GetCurrentDirectory(), ".build", "nuget.exe")}' commandline='restore Mvc.sln'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 remove if possible

<PropertyGroup>
<TargetFrameworks>net451;netcoreapp1.1</TargetFrameworks>
<RuntimeIdentifiers>win7-x64;win7-x86;osx.10.10-x64;osx.10.11-x64;ubuntu.14.04-x64;ubuntu.16.04-x64;centos.7-x64;rhel.7.2-x64;debian.8-x64;fedora.23-x64;opensuse.13.2-x64</RuntimeIdentifiers>
<RuntimeIdentifier Condition=" '$(TargetFramework)' == 'net451' ">win7-x86</RuntimeIdentifier>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To make this work, you need to invert the logic:

Condition=" '$(TargetFramework)' != 'netcoreapp1.1' "

</PropertyGroup>

<ItemGroup>
<Content Update="Views\**\*;web.config;wwwroot">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this whole line can be removed. IIUC this is handled by default by Microsoft.NET.Sdk.Web

</ItemGroup>

<ItemGroup>
<DotNetCliToolReference Include="Microsoft.DotNet.Watcher.Tools" Version="1.0.0-msbuild3-final" />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use version 1.0.1-* (latest on dev feed)

<VersionPrefix>1.2.0</VersionPrefix>
<TargetFrameworks>net451;netstandard1.6</TargetFrameworks>
<NoWarn>$(NoWarn);CS1591</NoWarn>
<WarningsAsErrors>true</WarningsAsErrors>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI: this is now TreatWarningsAsErrors

</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0-*" />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: sort alphabetically

</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp1.1' ">
<PackageReference Include="System.Diagnostics.TraceSource" Version="4.4.0-*" />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This package isn't actually required. cc @pranavkm I'm not sure why we added it to all of our test projects, but I've been removing this.

@@ -16,7 +16,7 @@ private static void DomainFunc()
accessor.ActionContext = new ActionContext();
}

[Fact]
[Fact(Skip = "https://github.com/Microsoft/vstest/issues/419")]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try the AppDomainSetup.ApplicationBase workaround I mentioned in microsoft/vstest#419

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any idea where that guy lives in coreclr world?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The equivalent in .net core is System.AppContext.BaseDirectory

</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp1.1' ">
<PackageReference Include="System.Diagnostics.TraceSource" Version="4.4.0-*" />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, probably not required.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Poking around to find out where it is required. Some of our tests do need it.

Copy link
Contributor

@natemcmaster natemcmaster left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few more things:

</PropertyGroup>

<ItemGroup>
<Compile Remove="TestFiles\**" />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider instead setting <DefaultItemExcludes>$(DefaultItemExcludes);TestFiles\**</DefaultItemExcludes>

@@ -0,0 +1,25 @@
<Project Sdk="Microsoft.NET.Sdk">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Btw, .notest was a simple workaround. When we get repo.targets, we can control the test projects better.

<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="1.2.0-*" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net451' ">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the references in this itemgroup are made redundant by the reference to NETStandard.Library.

</PropertyGroup>

<ItemGroup>
<Content Update="Areas\Area1\Views\**\*;Views\**\*;web.config;wwwroot\**\*">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be removed. Microsoft.NET.Sdk.Web should pick these up.

@NTaylorMullen
Copy link
Contributor Author

🆙 📅

Copy link
Member

@dougbu dougbu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you tried running / debugging the test/WebSites from VS or the command line? I'd guess many of the views now work only when invoked from the functional tests due to the odd <Content> requirements in the new world.
Further, if .cshtml edits aren't picked up on browser refresh, will slow future development down.

<PropertyGroup>
<TargetFrameworks>net451;netcoreapp1.1</TargetFrameworks>
<RuntimeIdentifier Condition=" '$(TargetFramework)' != 'netcoreapp1.1' ">win7-x64</RuntimeIdentifier>
<PreserveCompilationContext>true</PreserveCompilationContext>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't need to set $(PreserveCompilationContext) when using Microsoft.NET.Sdk.Web. Applies a lot in this PR.

[InlineData("POST")]
public async Task ApiExplorer_HttpMethod_Single(string httpMethod)
[Fact]
public async Task ApiExplorer_HttpMethod_Single_PUT()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Get why the GET method needs to be renamed. But, can't this still be a [Theory] for POST and PUT?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rynowak has convinced me that theories are evil 😄

@@ -0,0 +1,53 @@
TpTrace Verbose: 0 : 13980, 1, 2017/02/02, 12:42:31.591, 218211137537, vstest.console.dll, TestPluginCache: Discovering the extensions using extension path.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are these two testOutput files? Why do they need to be checked in?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol, nope, total fail on my part. will remove.

@@ -0,0 +1,3 @@
{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please stick a comment somewhere explaining why two test projects can't use shadow copying.

"microsoft.aspnetcore.mvc.webapicompatshim",
"microsoft.aspnetcore.mvc.testcommon",
"microsoft.aspnetcore.mvc.core.test",
"microsoft.aspnetcore.mvc.testdiagnosticlistener.sources",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

microsoft.aspnetcore.mvc.testdiagnosticlistener.sources.dll should never exist.

</PropertyGroup>

<ItemGroup>
<Compile Include="..\..\shared\Microsoft.AspNetCore.Mvc.TestDiagnosticListener.Sources\**\*.cs" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't need the **\ part of this path. Same for a few other references to these shared sources.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dougbu why not? Because there aren't any subfolders there right now, or because it's genuinely not required? If it just happens to work right now because there aren't sub-folders, we definitely need to keep it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🆗 @Eilon. As you thought, my comment was about the current state. I also didn't think we'd be likely to add files at all -- let alone in sub-folders.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dougbu yeah unfortunately we never know, so better safe than sorry. If there are other places where we aren't doing this, we should fix those to use a recursive glob pattern.

<PropertyGroup>
<TargetFrameworks>netcoreapp1.1;</TargetFrameworks>
<DefineConstants>$(DefineConstants);__RemoveThisBitTo__GENERATE_BASELINES;FUNCTIONAL_TESTS</DefineConstants>
<PackageTargetFallback>$(PackageTargetFallback);portable-net451+win8</PackageTargetFallback>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I may have missed discussion earlier in this PR; sorry if so. Why are we no longer running the functional tests with .NET 4.5.1?

Separately, I assume the $(PackageTargetFallback) setting is much like an "imports" value in project.json file. That did exist in this project. But, do we still need this setting?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dougbu cuz it ain't supported! .NET Core only.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Plus, in the case of this PR, the tests don't work for external reasons, so we can't run them 😄

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I asked because I wasn't aware of the specific external issues breaking these tests with desktop .NET.

@@ -0,0 +1,26 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this site work when started from the command line? I suspect you need a <Content Update...> because the Web SDK only sets $(CopyToPublishDirectory) for content it matches, not $(CopyToOutputDirectory).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It works, no worries 😄

- Allow >= RC3 CLI's to build and run MVC.
- Added extra sln's so they could be opened in VS. Currently VS' project system can't currently handle Mvc.sln.
- Worked around several dotnet migration issues. They are listed in the re-attempted migration section here: #5482
- One large feature bit that couldn't be worked around was the functional tests running on desktop; it represented several known vstest issues. Removed desktop running of functional tests.
- Skipped an ActionContextAccessor test due to a vstest appdomain problem.
@natemcmaster
Copy link
Contributor

natemcmaster commented Feb 9, 2017

@NTaylorMullen just updated KoreBuild to build solutions instead of individual csproj. This is the only solution that has multiple *.sln files, so you'll need to add the following to a file named "build/repo.targets"

<Project>
  <ItemGroup>
     <Solutions Include="$(MSBuildThisFileDirectory)..\Mvc.sln" />
  </ItemGroup>
</Project>

@natemcmaster
Copy link
Contributor

Any progress on this? It's the last repo on project.json.

@NTaylorMullen
Copy link
Contributor Author

Any progress on this? It's the last repo on project.json.

Still waiting on VS folks to give us a build of VS that doesn't deadlock/hang repeatedly when opening the solution.

@dougbu
Copy link
Member

dougbu commented Feb 21, 2017

I'll push this work forward (well, hopefully forward) while @NTaylorMullen is OOF. Will do this in a new branch temporarily. Once things stabilize, I'll push new commits here to maintain the threads above.

@dougbu dougbu mentioned this pull request Feb 23, 2017
@dougbu
Copy link
Member

dougbu commented Feb 23, 2017

For now at least, please direct all comments to #5852.

@natemcmaster
Copy link
Contributor

Can we just close this one?

@dougbu
Copy link
Member

dougbu commented Feb 23, 2017

Can we just close this one?

I'm leaving that up to @NTaylorMullen

@NTaylorMullen
Copy link
Contributor Author

Closing in favor of #5852

@dougbu dougbu deleted the nimullen/migration branch July 15, 2018 03:46
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants