示例#1
0
            /// <summary>
            /// Fills the provided CommandLineBuilderExtension with all the command line options used when
            /// executing this tool that must go on the command line
            /// </summary>
            /// <comments>
            /// Has to be command line commands because ResGen 3.5 and earlier don't know about
            /// response files.
            /// </comments>
            /// <param name="commandLine">Gets filled with command line options</param>
            protected internal override void AddCommandLineCommands(CommandLineBuilderExtension commandLine)
            {
                ErrorUtilities.VerifyThrow(!ResGen.IsNullOrEmpty(InputFiles), "If InputFiles is empty, the task should have returned before reaching this point");

                CommandLineBuilderExtension resGenArguments = new CommandLineBuilderExtension();

                GenerateResGenCommands(resGenArguments, false /* don't line-delimit arguments; spaces are just fine */);

                string pathToResGen = GenerateResGenFullPath();

                if (
                    pathToResGen != null &&
                    !pathToResGen.Equals(NativeMethodsShared.GetLongFilePath(ToolLocationHelper.GetPathToDotNetFrameworkSdkFile("resgen.exe", TargetDotNetFrameworkVersion.Version35)), StringComparison.OrdinalIgnoreCase) &&
                    String.IsNullOrEmpty(StronglyTypedLanguage)
                    )
                {
                    // 4.0 resgen.exe does support response files (at least as long as you're not building an STR), so we can
                    // make use of them here by returning nothing!
                }
                else
                {
                    // otherwise, the toolname is ResGen.exe and we just need the resgen arguments in CommandLineCommands.
                    commandLine.AppendTextUnquoted(resGenArguments.ToString());
                }
            }
示例#2
0
            /// <summary>
            /// Generates the full path to ResGen.exe.
            /// </summary>
            /// <returns>The path to ResGen.exe, or null.</returns>
            private string GenerateResGenFullPath()
            {
                string pathToTool = null;

                // Use ToolPath if it exists.
                pathToTool = (string)Bag["ToolPathWithFile"];

                if (pathToTool == null)
                {
                    // First see if the user has set ToolPath
                    if (ToolPath != null)
                    {
                        pathToTool = Path.Combine(ToolPath, ToolExe);

                        if (!File.Exists(pathToTool))
                        {
                            pathToTool = null;
                        }
                    }

                    // If it still hasn't been found, try to generate the appropriate path.
                    if (pathToTool == null)
                    {
                        pathToTool = SdkToolsPathUtility.GeneratePathToTool
                                     (
                            SdkToolsPathUtility.FileInfoExists,
                            MSBuildProcessorArchitecture.CurrentProcessArchitecture,
                            SdkToolsPath,
                            ToolName,
                            Log,
                            true                 /* log errors and warnings */
                                     );

                        pathToTool = NativeMethodsShared.GetLongFilePath(pathToTool);
                    }

                    // And then set it for future reference.  If it's still null, there's nothing else
                    // we can do, and we've already logged an appropriate error.
                    Bag["ToolPathWithFile"] = pathToTool;
                }

                return(pathToTool);
            }