Exemple #1
0
        private string ProjectHeader(
            Compilation.Assembly assembly,
            IEnumerable <ResponseFileData> responseFilesData)
        {
            string targetframeworkversion = "v4.7.1";
            string targetLanguageVersion  = "latest";
            string toolsversion           = "4.0";
            string productversion         = "10.0.20506";
            string baseDirectory          = ".";
            string cscToolPath            = "$(CscToolPath)";

            cscToolPath = Paths.Combine(EditorApplication.applicationContentsPath, "Tools", "RoslynScripts");
            cscToolPath = Paths.UnifyDirectorySeparator(cscToolPath);
            string cscToolExe = Application.platform == RuntimePlatform.WindowsEditor ? "unity_csc.bat" : "unity_csc.sh";

            var arguments = new object[]
            {
                toolsversion,
                productversion,
                ProjectGuid(assembly.name),
                _settings.EngineAssemblyPath,
                _settings.EditorAssemblyPath,
                string.Join(";", assembly.defines.Concat(responseFilesData.SelectMany(x => x.Defines)).Distinct().ToArray()),
                MSBuildNamespaceUri,
                Path.GetFileNameWithoutExtension(assembly.outputPath),
                m_assemblyNameProvider.GetCompileOutputPath(assembly.name),
                m_assemblyNameProvider.ProjectGenerationRootNamespace,
                targetframeworkversion,
                targetLanguageVersion,
                baseDirectory,
                assembly.compilerOptions.AllowUnsafeCode | responseFilesData.Any(x => x.Unsafe),
                cscToolPath,
                cscToolExe,
            };

            try
            {
                ScriptingLanguage language = ScriptingLanguageFor(assembly);
                return(string.Format(_settings.GetProjectHeaderTemplate(language), arguments));
            }
            catch (Exception)
            {
                throw new System.NotSupportedException("Failed creating c# project because the c# project header did not have the correct amount of arguments, which is " + arguments.Length);
            }
        }