public void WriteProject_NewProjectReferenceAddedWithNameAndProjectMetadata_ProjectReferenceSavedWithJustIncludeNotNameAndProject() { CreateMSBuildProject( "<Project Sdk=\"Microsoft.NET.Sdk\">\r\n" + " <PropertyGroup>\r\n" + " <OutputType>Exe</OutputType>\r\n" + " <TargetFramework>netcoreapp1.0</TargetFramework>\r\n" + " </PropertyGroup>\r\n" + "</Project>"); ReadProject(); project.HasSdk = true; var projectReferenceItem = msbuildProject.AddNewItem("ProjectReference", @"Lib\Lib.csproj"); projectReferenceItem.Metadata.SetValue("Name", "Lib"); projectReferenceItem.Metadata.SetValue("Project", "{F109E7DF-F561-4CD6-A46E-CFB27A8B6F2C}"); WriteProject(); var projectReferenceSaved = msbuildProject.GetAllItems() .FirstOrDefault(item => item.Name == "ProjectReference"); Assert.IsFalse(projectReferenceSaved.Metadata.HasProperty("Name")); Assert.IsFalse(projectReferenceSaved.Metadata.HasProperty("Project")); Assert.AreEqual(@"Lib\Lib.csproj", projectReferenceSaved.Include); }
public void Write_Version_WrittenAsAttribute() { var p = new MSBuildProject(); p.LoadXml("<Project ToolsVersion=\"15.0\" />"); ProjectPackageReference.AddKnownItemAttributes(p); var item = p.AddNewItem("PackageReference", "Test"); var packageReference = new TestableProjectPackageReference("Test", "1.2.3"); packageReference.CallWrite(item); string xml = p.SaveToString(); var doc = new XmlDocument(); doc.LoadXml(xml); var itemGroupElement = (XmlElement)doc.DocumentElement.ChildNodes[0]; var packageReferenceElement = (XmlElement)itemGroupElement.ChildNodes[0]; Assert.AreEqual("PackageReference", packageReferenceElement.Name); Assert.AreEqual("1.2.3", packageReferenceElement.GetAttribute("Version")); Assert.AreEqual(0, packageReferenceElement.ChildNodes.Count); Assert.IsTrue(packageReferenceElement.IsEmpty); }