Merge pull request #2930 from eerhardt/MvcNet46
dotnet build raises errors MVC apps target net46.
This commit is contained in:
commit
a76fea647e
5 changed files with 49 additions and 6 deletions
|
@ -0,0 +1 @@
|
||||||
|
noautobuild
|
10
TestAssets/TestProjects/AppWithNet46AndRoslyn/Program.cs
Normal file
10
TestAssets/TestProjects/AppWithNet46AndRoslyn/Program.cs
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
namespace AppWithNet46AndRoslyn
|
||||||
|
{
|
||||||
|
public class MyApp
|
||||||
|
{
|
||||||
|
public static void Main()
|
||||||
|
{
|
||||||
|
System.Console.WriteLine("Hello, World!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
11
TestAssets/TestProjects/AppWithNet46AndRoslyn/project.json
Normal file
11
TestAssets/TestProjects/AppWithNet46AndRoslyn/project.json
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
{
|
||||||
|
"buildOptions": {
|
||||||
|
"emitEntryPoint": true
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"Microsoft.CodeAnalysis.CSharp": "1.3.0-beta1-20160429-01"
|
||||||
|
},
|
||||||
|
"frameworks": {
|
||||||
|
"net46": { }
|
||||||
|
}
|
||||||
|
}
|
|
@ -440,15 +440,21 @@ namespace Microsoft.DotNet.ProjectModel
|
||||||
package.HasCompileTimePlaceholder &&
|
package.HasCompileTimePlaceholder &&
|
||||||
!TargetFramework.IsPackageBased)
|
!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 newKey = new LibraryKey(library.Identity.Name, LibraryType.ReferenceAssembly);
|
||||||
var dependency = new LibraryRange(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
|
var replacement = referenceAssemblyDependencyResolver.GetDescription(dependency, TargetFramework);
|
||||||
// dependency
|
|
||||||
var replacement = referenceAssemblyDependencyResolver.GetDescription(dependency, TargetFramework) ??
|
|
||||||
UnresolvedDependencyProvider.GetDescription(dependency, TargetFramework);
|
|
||||||
|
|
||||||
requiresFrameworkAssemblies = true;
|
// If the reference is unresolved, just skip it. Don't replace the package dependency
|
||||||
|
if (replacement == null)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// Remove the original package reference
|
// Remove the original package reference
|
||||||
libraries.Remove(pair.Key);
|
libraries.Remove(pair.Key);
|
||||||
|
|
|
@ -100,5 +100,20 @@ namespace Microsoft.DotNet.Tools.Builder.Tests
|
||||||
"TestLibraryWithXmlDoc.xml"
|
"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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue