public void ProjectWithSdkImportsIsRemoveable(string projectFormatString) { _env.SetEnvironmentVariable("MSBuildSDKsPath", _testSdkRoot); string projectInnerContents = @" <PropertyGroup> <OutputType>Exe</OutputType> <TargetFramework>netcoreapp1.0</TargetFramework> </PropertyGroup> <ItemGroup> <Compile Include=""**\*.cs"" /> <EmbeddedResource Include=""**\*.resx"" /> </ItemGroup> <ItemGroup> <PackageReference Include=""Microsoft.NETCore.App"" Version=""1.0.1"" /> </ItemGroup>"; File.WriteAllText(_sdkPropsPath, " <Project />"); File.WriteAllText(_sdkTargetsPath, "<Project />"); // Based on the new-console-project CLI template (but not matching exactly // should not be a deal-breaker). string content = string.Format(projectFormatString, SdkName, projectInnerContents); ProjectRootElement project = ProjectRootElement.Create(XmlReader.Create(new StringReader(content))); ProjectRootElement clone = ProjectRootElement.Create(XmlReader.Create(new StringReader(content))); clone.DeepCopyFrom(project); clone.RemoveAllChildren(); }
public void ProjectWithSdkImportsIsRemoveable() { File.WriteAllText(_sdkPropsPath, "<Project />"); File.WriteAllText(_sdkTargetsPath, "<Project />"); using (new Helpers.TemporaryEnvironment("MSBuildSDKsPath", _testSdkRoot)) { // Based on the new-console-project CLI template (but not matching exactly // should not be a deal-breaker). string content = $@"<Project Sdk=""{SdkName}"" ToolsVersion=""15.0""> <PropertyGroup> <OutputType>Exe</OutputType> <TargetFramework>netcoreapp1.0</TargetFramework> </PropertyGroup> <ItemGroup> <Compile Include=""**\*.cs"" /> <EmbeddedResource Include=""**\*.resx"" /> </ItemGroup> <ItemGroup> <PackageReference Include=""Microsoft.NETCore.App"" Version=""1.0.1"" /> </ItemGroup> </Project>"; ProjectRootElement project = ProjectRootElement.Create(XmlReader.Create(new StringReader(content))); ProjectRootElement clone = ProjectRootElement.Create(XmlReader.Create(new StringReader(content))); clone.DeepCopyFrom(project); clone.RemoveAllChildren(); } }