Example #1
0
        private static string MakeDefaultTargetFrameworkDefine(NuGetFramework targetFramework)
        {
            var candidateName = targetFramework.GetTwoDigitShortFolderName().ToUpperInvariant();

            if (targetFramework.IsPCL && string.IsNullOrWhiteSpace(targetFramework.Profile))
            {
                return(null);
            }
            else
            {
                candidateName = $"{FrameworkConstants.FrameworkIdentifiers.Portable.TrimStart('.')}_{targetFramework.Profile}".ToUpperInvariant();
            }

            // Replace '-', '.', and '+' in the candidate name with '_' because TFMs with profiles use those (like "net40-client")
            // and we want them representable as defines (i.e. "NET40_CLIENT")
            candidateName = candidateName.Replace('-', '_').Replace('+', '_').Replace('.', '_');

            // We require the following from our Target Framework Define names
            // Starts with A-Z or _
            // Contains only A-Z, 0-9 and _
            if (!string.IsNullOrEmpty(candidateName) &&
                (char.IsLetter(candidateName[0]) || candidateName[0] == '_') &&
                candidateName.All(c => Char.IsLetterOrDigit(c) || c == '_'))
            {
                return(candidateName);
            }

            return(null);
        }
Example #2
0
        public string GetIntermediateOutputDirectoryPath(string buildConfiguration, string intermediateOutputValue)
        {
            string intermediateOutputPath;

            if (string.IsNullOrEmpty(intermediateOutputValue))
            {
                intermediateOutputPath = Path.Combine(
                    BaseOutputPath,
                    ObjDirectoryName,
                    buildConfiguration,
                    _framework.GetTwoDigitShortFolderName());
            }
            else
            {
                intermediateOutputPath = intermediateOutputValue;
            }

            return(intermediateOutputPath);
        }
Example #3
0
 public static string GetMSBuildCondition(this NuGetFramework framework)
 {
     return($" '$(TargetFramework)' == '{framework.GetTwoDigitShortFolderName()}' ");
 }
Example #4
0
        public static OutputPaths GetOutputPaths(
            Project project,
            NuGetFramework framework,
            string runtimeIdentifier,
            string configuration,
            string solutionRootPath,
            string buildBasePath,
            string outputPath)
        {
            string resolvedBuildBasePath;

            if (string.IsNullOrEmpty(buildBasePath))
            {
                resolvedBuildBasePath = project.ProjectDirectory;
            }
            else
            {
                if (string.IsNullOrEmpty(solutionRootPath))
                {
                    resolvedBuildBasePath = Path.Combine(buildBasePath, project.Name);
                }
                else
                {
                    resolvedBuildBasePath = project.ProjectDirectory.Replace(solutionRootPath, buildBasePath);
                }
            }

            var compilationOutputPath = PathUtility.EnsureTrailingSlash(Path.Combine(resolvedBuildBasePath,
                                                                                     BinDirectoryName,
                                                                                     configuration,
                                                                                     framework.GetShortFolderName()));

            string runtimeOutputPath = null;

            if (string.IsNullOrEmpty(outputPath))
            {
                if (!string.IsNullOrEmpty(runtimeIdentifier))
                {
                    runtimeOutputPath = PathUtility.EnsureTrailingSlash(Path.Combine(compilationOutputPath, runtimeIdentifier));
                }
                else
                {
                    // "Runtime" assets (i.e. the deps file) will be dropped to the compilation output path, because
                    // we are building a RID-less target.
                    runtimeOutputPath = compilationOutputPath;
                }
            }
            else
            {
                runtimeOutputPath = PathUtility.EnsureTrailingSlash(Path.GetFullPath(outputPath));
            }

            var intermediateOutputPath = PathUtility.EnsureTrailingSlash(Path.Combine(
                                                                             resolvedBuildBasePath,
                                                                             ObjDirectoryName,
                                                                             configuration,
                                                                             framework.GetTwoDigitShortFolderName()));

            var compilationFiles = new CompilationOutputFiles(compilationOutputPath, project, configuration, framework);

            RuntimeOutputFiles runtimeFiles = null;

            if (runtimeOutputPath != null)
            {
                runtimeFiles = new RuntimeOutputFiles(runtimeOutputPath, project, configuration, framework);
            }
            return(new OutputPaths(intermediateOutputPath, compilationOutputPath, runtimeOutputPath, compilationFiles, runtimeFiles));
        }