Beispiel #1
0
        /// <summary>
        /// Adds a text file to content files in the package.
        /// </summary>
        /// <param name="relativePath">The filename or relative path to the file.</param>
        /// <param name="contents">The contents of the file.</param>
        /// <param name="targetFramework">The target framework for the content file.</param>
        /// <param name="buildAction">The build action of the content file.</param>
        /// <param name="copyToOutput"><c>true</c> to copy the content file to the build output folder, otherwise <c>false</c>.</param>
        /// <param name="flatten"><c>true</c> to flatten the file structure by disregarding subfolders, otherwise <c>false</c></param>
        /// <param name="language">An optional language for the content file.  The default value is "any".</param>
        /// <returns>The current <see cref="PackageFeed" />.</returns>
        public PackageFeed ContentFileText(string relativePath, string contents, string targetFramework, string buildAction, bool copyToOutput = false, bool flatten = false, string language = "any")
        {
            string contentFilePath = Path.Combine(language, targetFramework, relativePath);

            LastPackage.AddContentFile(new PackageContentFileEntry
            {
                BuildAction  = buildAction,
                CopyToOutput = copyToOutput,
                Include      = contentFilePath,
                Flatten      = flatten,
            });

            return(FileText(Path.Combine("contentFiles", contentFilePath), contents));
        }
        /// <summary>
        /// Adds a dependency to the current package.
        /// </summary>
        /// <param name="id">The identifier of the dependency.</param>
        /// <param name="version">The version of the dependency.</param>
        /// <param name="targetFramework">The target framework for the dependency.</param>
        /// <param name="includeAssets">An optional array of strings representing the assets to include for the dependency.</param>
        /// <param name="excludeAssets">An optional array of strings representing the assets to exclude from the dependency.</param>
        /// <returns>The current <see cref="PackageRepository" />.</returns>
        public PackageRepository Dependency(string id, string version, string targetFramework, string?includeAssets = "All", string?excludeAssets = "None")
        {
            if (LastPackage == null)
            {
                throw new InvalidOperationException(Strings.ErrorWhenAddingLibraryRequiresPackage);
            }

            LastPackage.AddTargetFramework(targetFramework);

            LastPackage.AddDependency(targetFramework, id, version, includeAssets, excludeAssets);

            SavePackageManifest();

            return(this);
        }
Beispiel #3
0
        /// <summary>
        /// Adds a library to the package.
        /// </summary>
        /// <param name="targetFramework">The target framework of the library.</param>
        /// <param name="filename">An optional filename for the library.  The default value is &lt;PackageId&gt;.dll.</param>
        /// <param name="namespace">An optional namespace for the library.  The default value is &lt;PackageId&gt;.</param>
        /// <param name="className">An optional class name for the library.  The default value is &lt;PackageId&gt;_Class.</param>
        /// <param name="assemblyVersion">An optional assembly version for the library.  The default value is &quot;1.0.0.0&quot;</param>
        /// <returns>The current <see cref="PackageRepository" />.</returns>
        public PackageRepository Library(string targetFramework, string?filename = null, string? @namespace = null, string?className = null, string assemblyVersion = "1.0.0.0")
        {
            if (LastPackage == null)
            {
                throw new InvalidOperationException(Strings.ErrorWhenAddingLibraryRequiresPackage);
            }

            if (string.IsNullOrWhiteSpace(filename))
            {
                filename = $"{LastPackage.Id}.dll";
            }

            if (string.IsNullOrWhiteSpace(@namespace))
            {
                @namespace = LastPackage.Id;
            }

            if (string.IsNullOrWhiteSpace(className))
            {
                className = $"{LastPackage.Id}_Class";
            }

            LastPackage.AddTargetFramework(targetFramework);

            return(File(
                       Path.Combine("lib", targetFramework, filename !),
                       fileInfo =>
            {
                fileInfo.Directory !.Create();

                using (Stream stream = System.IO.File.Create(fileInfo.FullName))
                {
                    AssemblyCreator.Create(stream, Path.GetFileNameWithoutExtension(filename), @namespace !, className !, assemblyVersion, targetFramework);
                }
            }));
        }
        /// <summary>
        /// Adds a dependency to the current package.
        /// </summary>
        /// <param name="targetFramework">The target framework of the dependency.</param>
        /// <param name="id">The package ID of the dependency.</param>
        /// <param name="version">The minimum version of the dependency.</param>
        /// <param name="include">An optional comma delimited list of assets to include.  The default value is All.</param>
        /// <param name="exclude">An optional comma delimited list of assets to exclude.  The default value is None.</param>
        /// <returns>The current <see cref="PackageFeed" />.</returns>
        public PackageFeed Dependency(string targetFramework, string id, string version, string include = "All", string exclude = "None")
        {
            LastPackage.AddDependency(targetFramework, id, version, include, exclude);

            return(this);
        }
Beispiel #5
0
        private PackageFeed File(string relativePath, Func <MemoryStream> streamFunc)
        {
            LastPackage.AddFile(relativePath, streamFunc);

            return(this);
        }
Beispiel #6
0
        /// <summary>
        /// Adds a custom file to a package.
        /// </summary>
        /// <param name="relativePath">The relative path of the file within the package.</param>
        /// <param name="sourceFileInfo">The <see cref="FileInfo" /> of the file to copy from.</param>
        /// <returns>The current <see cref="PackageFeed" />.</returns>
        public PackageFeed FileCustom(string relativePath, FileInfo sourceFileInfo)
        {
            LastPackage.AddFile(relativePath, sourceFileInfo);

            return(this);
        }