public string ProjectFile(Assembly assembly) { return(Path.Combine(ProjectDirectory, $"{m_AssemblyNameProvider.GetAssemblyName(assembly.outputPath, assembly.name)}.csproj")); }
private string ProjectText(Assembly assembly, Dictionary <string, string> allAssetsProjectParts, ResponseFileData[] responseFilesData) { var projectBuilder = new StringBuilder(ProjectHeader(assembly, responseFilesData)); var references = new List <string>(); projectBuilder.Append(@" <ItemGroup>").Append(k_WindowsNewline); foreach (string file in assembly.sourceFiles) { if (!IsSupportedFile(file)) { continue; } var extension = Path.GetExtension(file).ToLower(); var fullFile = EscapedRelativePathFor(file); if (".dll" != extension) { projectBuilder.Append(" <Compile Include=\"").Append(fullFile).Append("\" />").Append(k_WindowsNewline); } else { references.Add(fullFile); } } projectBuilder.Append(@" </ItemGroup>").Append(k_WindowsNewline); // Append additional non-script files that should be included in project generation. if (allAssetsProjectParts.TryGetValue(assembly.name, out var additionalAssetsForProject)) { projectBuilder.Append(@" <ItemGroup>").Append(k_WindowsNewline); projectBuilder.Append(additionalAssetsForProject); projectBuilder.Append(@" </ItemGroup>").Append(k_WindowsNewline); } projectBuilder.Append(@" <ItemGroup>").Append(k_WindowsNewline); var responseRefs = responseFilesData.SelectMany(x => x.FullPathReferences.Select(r => r)); var internalAssemblyReferences = assembly.assemblyReferences .Where(i => !i.sourceFiles.Any(ShouldFileBePartOfSolution)).Select(i => i.outputPath); var allReferences = assembly.compiledAssemblyReferences .Union(responseRefs) .Union(references) .Union(internalAssemblyReferences); foreach (var reference in allReferences) { string fullReference = Path.IsPathRooted(reference) ? reference : Path.Combine(ProjectDirectory, reference); AppendReference(fullReference, projectBuilder); } projectBuilder.Append(@" </ItemGroup>").Append(k_WindowsNewline); if (0 < assembly.assemblyReferences.Length) { projectBuilder.Append(" <ItemGroup>").Append(k_WindowsNewline); foreach (var reference in assembly.assemblyReferences.Where(i => i.sourceFiles.Any(ShouldFileBePartOfSolution))) { // If the current assembly is a Player project, we want to project-reference the corresponding Player project var referenceName = m_AssemblyNameProvider.GetAssemblyName(assembly.outputPath, reference.name); projectBuilder.Append(" <ProjectReference Include=\"").Append(referenceName).Append(GetProjectExtension()).Append("\">").Append(k_WindowsNewline); projectBuilder.Append(" <Project>{").Append(ProjectGuid(referenceName)).Append("}</Project>").Append(k_WindowsNewline); projectBuilder.Append(" <Name>").Append(referenceName).Append("</Name>").Append(k_WindowsNewline); projectBuilder.Append(" </ProjectReference>").Append(k_WindowsNewline); } projectBuilder.Append(@" </ItemGroup>").Append(k_WindowsNewline); } projectBuilder.Append(GetProjectFooter()); return(projectBuilder.ToString()); }