public void SettingsFromPropsFileImportedUsingAbsolutePathGetCopies() { const string imported = @" <Project> <PropertyGroup> <LangVersion>9.9</LangVersion> </PropertyGroup> </Project> "; var propsFilePath = Path.Combine(TestAssemblyFileInfo.DirectoryName, "test.props"); File.WriteAllText(propsFilePath, imported); string importingAbsolutePath = $@" <Project Sdk=""Microsoft.NET.Sdk""> <Import Project=""{propsFilePath}"" /> </Project>"; var sut = new CsProjGenerator("netcoreapp3.0", null, null, null); using (var reader = new StringReader(importingAbsolutePath)) { var(customProperties, sdkName) = sut.GetSettingsThatNeedsToBeCopied(reader, TestAssemblyFileInfo); Assert.Equal("<LangVersion>9.9</LangVersion>", customProperties); Assert.Equal("Microsoft.NET.Sdk", sdkName); } File.Delete(propsFilePath); }
private void AssertParsedSdkName(string csProjContent, string targetFrameworkMoniker, string expectedSdkValue) { var sut = new CsProjGenerator(targetFrameworkMoniker, null, null, null); using (var reader = new StringReader(csProjContent)) { var(customProperties, sdkName) = sut.GetSettingsThatNeedsToBeCopied(reader, TestAssemblyFileInfo); Assert.Equal(expectedSdkValue, sdkName); Assert.Empty(customProperties); } }
public void UseWpfSettingGetsCopied() { const string withUseWpfTrue = @" <Project Sdk=""Microsoft.NET.Sdk""> <PropertyGroup> <PlatformTarget>AnyCPU</PlatformTarget> <UseWpf>true</UseWpf> </PropertyGroup> </Project> "; var sut = new CsProjGenerator("netcoreapp3.0", null, null, null); using (var reader = new StringReader(withUseWpfTrue)) { var(customProperties, sdkName) = sut.GetSettingsThatNeedsToBeCopied(reader, TestAssemblyFileInfo); Assert.Equal("<UseWpf>true</UseWpf>", customProperties); Assert.Equal("Microsoft.NET.Sdk", sdkName); } }