/// <summary> /// Converts a VS7/Everett project to Whidbey format, and compares the result with the expected /// contents to make sure they match. /// </summary> /// <param name="everettProjectContents"></param> /// <param name="whidbeyProjectContents"></param> /// <param name="additionalDummyFileToCreateInEverettProjectDirectory"></param> /// <param name="isMinorUpgrade"></param> /// <owner>RGoel</owner> internal static void ConvertAndCompare ( string sourceProjectContents, string targetProjectContents, string additionalDummyFileToCreateInEverettProjectDirectory, bool isMinorUpgrade = false ) { string sourceProjectFile = ObjectModelHelpers.CreateTempFileOnDiskNoFormat(sourceProjectContents); string dummyExtraFile = null; if (additionalDummyFileToCreateInEverettProjectDirectory != null) { dummyExtraFile = Path.Combine(Path.GetDirectoryName(sourceProjectFile), additionalDummyFileToCreateInEverettProjectDirectory); File.WriteAllText(dummyExtraFile, String.Empty); } try { ProjectFileConverter converter = new ProjectFileConverter(); converter.OldProjectFile = sourceProjectFile; converter.IsUserFile = false; converter.IsMinorUpgrade = isMinorUpgrade; ProjectRootElement project = converter.ConvertInMemory(); Helpers.CompareProjectXml(targetProjectContents, project.RawXml); } finally { File.Delete(sourceProjectFile); if (dummyExtraFile != null) { File.Delete(dummyExtraFile); } } }
public void ConvertP2PReferenceSearchForSolution() { ObjectModelHelpers.DeleteTempProjectDirectory(); // ********************************************** // EVERETT PROJECT // ********************************************** string everettProjectFileRelativePath = @"Project\WindowsApplication1.csproj"; ObjectModelHelpers.CreateFileInTempProjectDirectory(everettProjectFileRelativePath, @" <VisualStudioProject> <CSHARP ProjectType = `Local` SchemaVersion = `2.0` ProjectGuid = `{77E21864-797C-4220-974E-530BB832801B}` > <Build> <Settings ApplicationIcon = `App.ico` > <Config Name = `Debug` OutputPath = `bin\Debug\` /> <Config Name = `Release` OutputPath = `bin\Release\` /> </Settings> <References> <Reference Name = `System` AssemblyName = `System` HintPath = `..\..\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.dll` /> <Reference Name = `System.XML` AssemblyName = `System.XML` HintPath = `..\..\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.XML.dll` /> <Reference Name = `ClassLibrary1` Project = `{F532DD6D-9E5C-4FE8-BE84-96F37D47F45A}` Package = `{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}` /> </References> </Build> <Files> <Include> <File RelPath = `Form1.cs` SubType = `Form` BuildAction = `Compile` /> <File RelPath = `Form1.resx` DependentUpon = `Form1.cs` BuildAction = `EmbeddedResource` /> </Include> </Files> </CSHARP> </VisualStudioProject> "); string resxFile = "Project\\Form1.resx"; ObjectModelHelpers.CreateFileInTempProjectDirectory(resxFile, String.Empty); // ********************************************** // EVERETT SOLUTION // ********************************************** ObjectModelHelpers.CreateFileInTempProjectDirectory(@"WindowsApplication1.sln", @"Microsoft Visual Studio Solution File, Format Version 8.00 Project(`{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}`) = `WindowsApplication1`, `Project\WindowsApplication1.csproj`, `{77E21864-797C-4220-974E-530BB832801B}` ProjectSection(ProjectDependencies) = postProject EndProjectSection EndProject Project(`{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}`) = `ClassLibrary1`, `ClassLibrary1\ClassLibrary1.csproj`, `{F532DD6D-9E5C-4FE8-BE84-96F37D47F45A}` ProjectSection(ProjectDependencies) = postProject EndProjectSection EndProject Global GlobalSection(SolutionConfiguration) = preSolution Debug = Debug Release = Release EndGlobalSection GlobalSection(ProjectConfiguration) = postSolution {77E21864-797C-4220-974E-530BB832801B}.Debug.ActiveCfg = Debug|.NET {77E21864-797C-4220-974E-530BB832801B}.Debug.Build.0 = Debug|.NET {77E21864-797C-4220-974E-530BB832801B}.Release.ActiveCfg = Release|.NET {77E21864-797C-4220-974E-530BB832801B}.Release.Build.0 = Release|.NET {F532DD6D-9E5C-4FE8-BE84-96F37D47F45A}.Debug.ActiveCfg = Debug|.NET {F532DD6D-9E5C-4FE8-BE84-96F37D47F45A}.Debug.Build.0 = Debug|.NET {F532DD6D-9E5C-4FE8-BE84-96F37D47F45A}.Release.ActiveCfg = Release|.NET {F532DD6D-9E5C-4FE8-BE84-96F37D47F45A}.Release.Build.0 = Release|.NET EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution EndGlobalSection GlobalSection(ExtensibilityAddIns) = postSolution EndGlobalSection EndGlobal "); // ********************************************** // RANDOM OTHER SOLUTION // ********************************************** ObjectModelHelpers.CreateFileInTempProjectDirectory(@"Project\Random.sln", @"Microsoft Visual Studio Solution File, Format Version 8.00 Project(`{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}`) = `ClassLibrary2`, `ClassLibrary2\ClassLibrary2.csproj`, `{11111111-9E5C-4FE8-BE84-96F37D47F45A}` ProjectSection(ProjectDependencies) = postProject EndProjectSection EndProject Global GlobalSection(SolutionConfiguration) = preSolution Debug = Debug Release = Release EndGlobalSection GlobalSection(ProjectConfiguration) = postSolution {11111111-9E5C-4FE8-BE84-96F37D47F45A}.Debug.ActiveCfg = Debug|.NET {11111111-9E5C-4FE8-BE84-96F37D47F45A}.Debug.Build.0 = Debug|.NET {11111111-9E5C-4FE8-BE84-96F37D47F45A}.Release.ActiveCfg = Release|.NET {11111111-9E5C-4FE8-BE84-96F37D47F45A}.Release.Build.0 = Release|.NET EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution EndGlobalSection GlobalSection(ExtensibilityAddIns) = postSolution EndGlobalSection EndGlobal "); // ********************************************** // WHIDBEY PROJECT // ********************************************** string whidbeyProjectContents = @" <Project ToolsVersion=`msbuilddefaulttoolsversion` xmlns=`msbuildnamespace` DefaultTargets=`Build`> <PropertyGroup> <ProjectType>Local</ProjectType> <SchemaVersion>2.0</SchemaVersion> <ProjectGuid>{77E21864-797C-4220-974E-530BB832801B}</ProjectGuid> <Configuration Condition=` '$(Configuration)' == '' `>Debug</Configuration> <Platform Condition=` '$(Platform)' == '' `>AnyCPU</Platform> <ApplicationIcon>App.ico</ApplicationIcon> <FileUpgradeFlags>20</FileUpgradeFlags> </PropertyGroup> <PropertyGroup Condition=` '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' `> <OutputPath>bin\Debug\</OutputPath> <ErrorReport>prompt</ErrorReport> </PropertyGroup> <PropertyGroup Condition=` '$(Configuration)|$(Platform)' == 'Release|AnyCPU' `> <OutputPath>bin\Release\</OutputPath> <ErrorReport>prompt</ErrorReport> </PropertyGroup> <ItemGroup> <ProjectReference Include=`..\ClassLibrary1\ClassLibrary1.csproj`> <Name>ClassLibrary1</Name> <Project>{F532DD6D-9E5C-4FE8-BE84-96F37D47F45A}</Project> <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package> </ProjectReference> <Reference Include=`System`> <Name>System</Name> </Reference> <Reference Include=`System.XML`> <Name>System.XML</Name> </Reference> </ItemGroup> <ItemGroup> <Compile Include=`Form1.cs`> <SubType>Form</SubType> </Compile> </ItemGroup> <Import Project=`$(MSBuildToolsPath)\Microsoft.CSharp.targets` /> <PropertyGroup> <PreBuildEvent /> <PostBuildEvent /> </PropertyGroup> </Project> "; ProjectFileConverter converter = new ProjectFileConverter(); converter.OldProjectFile = Path.Combine(ObjectModelHelpers.TempProjectDir, everettProjectFileRelativePath); converter.IsUserFile = false; ProjectRootElement project = converter.ConvertInMemory(); Helpers.CompareProjectXml(whidbeyProjectContents, project.RawXml); }