Merge pull request #2930 from eerhardt/MvcNet46

dotnet build raises errors MVC apps target net46.
This commit is contained in:
Eric Erhardt 2016-05-06 17:12:25 -05:00
commit a76fea647e
5 changed files with 49 additions and 6 deletions

View file

@ -0,0 +1 @@
noautobuild

View file

@ -0,0 +1,10 @@
namespace AppWithNet46AndRoslyn
{
public class MyApp
{
public static void Main()
{
System.Console.WriteLine("Hello, World!");
}
}
}

View file

@ -0,0 +1,11 @@
{
"buildOptions": {
"emitEntryPoint": true
},
"dependencies": {
"Microsoft.CodeAnalysis.CSharp": "1.3.0-beta1-20160429-01"
},
"frameworks": {
"net46": { }
}
}

View file

@ -440,15 +440,21 @@ namespace Microsoft.DotNet.ProjectModel
package.HasCompileTimePlaceholder &&
!TargetFramework.IsPackageBased)
{
// requiresFrameworkAssemblies is true whenever we find a CompileTimePlaceholder in a non-package based framework, even if
// the reference is unresolved. This ensures the best error experience when someone is building on a machine without
// the target framework installed.
requiresFrameworkAssemblies = true;
var newKey = new LibraryKey(library.Identity.Name, LibraryType.ReferenceAssembly);
var dependency = new LibraryRange(library.Identity.Name, LibraryType.ReferenceAssembly);
// If the framework assembly can't be resolved then mark it as unresolved but still replace the package
// dependency
var replacement = referenceAssemblyDependencyResolver.GetDescription(dependency, TargetFramework) ??
UnresolvedDependencyProvider.GetDescription(dependency, TargetFramework);
requiresFrameworkAssemblies = true;
var replacement = referenceAssemblyDependencyResolver.GetDescription(dependency, TargetFramework);
// If the reference is unresolved, just skip it. Don't replace the package dependency
if (replacement == null)
{
continue;
}
// Remove the original package reference
libraries.Remove(pair.Key);

View file

@ -100,5 +100,20 @@ namespace Microsoft.DotNet.Tools.Builder.Tests
"TestLibraryWithXmlDoc.xml"
});
}
[WindowsOnlyFact]
public void It_builds_projects_targeting_net46_and_Roslyn()
{
var testInstance = TestAssetsManager
.CreateTestInstance("AppWithNet46AndRoslyn")
.WithLockFiles();
var testProject = Path.Combine(testInstance.TestRoot, "project.json");
new BuildCommand(testProject)
.Execute()
.Should()
.Pass();
}
}
}