Created
          October 18, 2019 09:26 
        
      - 
      
- 
        Save iamkoch/4051da75681508bb0013667871f5a841 to your computer and use it in GitHub Desktop. 
    Bullseye + Dragonfruit
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | using System; | |
| using System.IO; | |
| using System.Linq; | |
| using System.Net; | |
| using System.Runtime.CompilerServices; | |
| using System.Xml.Linq; | |
| using static Bullseye.Targets; | |
| using static SimpleExec.Command; | |
| namespace build | |
| { | |
| class Program | |
| { | |
| private const string Build = "build"; | |
| private const string Test = "test"; | |
| private const string Publish = "publish"; | |
| public static int Main( | |
| string artifactsDirectory = "./artifacts", | |
| string testResultsDirectory = "/TestResults", | |
| string buildConfiguration = "Release") | |
| { | |
| Target(Build, () => Run("dotnet", $"build --configuration={buildConfiguration}")); | |
| Target( | |
| Test, | |
| DependsOn(Build), | |
| () => Run("dotnet", $"test --configuration={buildConfiguration} --no-build --no-restore --verbosity=normal --logger=trx --results-directory={testResultsDirectory}")); | |
| Target(Publish, DependsOn(Test), () => | |
| { | |
| var pathsToCsProjFiles = | |
| Directory | |
| .GetFiles("../", "*.csproj", new EnumerationOptions {RecurseSubdirectories = true}) | |
| .Select(x => (PathToCsProj: x, ParsedCsProj: XDocument.Load(x))) | |
| .Where(x => | |
| x.ParsedCsProj.Descendants("AWSProjectType").Count() == 1 | |
| && x.ParsedCsProj.Descendants("AWSProjectType").Single().Value.ToLower() == "lambda") | |
| .Select(x => x.PathToCsProj) | |
| .ToList() | |
| ; | |
| foreach (var pathToCsProjFile in pathsToCsProjFiles) | |
| { | |
| var fileInfo = new FileInfo(pathToCsProjFile); | |
| var filenameWithoutExtensions = fileInfo.Name.Replace(fileInfo.Extension, string.Empty); | |
| Run("dotnet",$"lambda package -pl {fileInfo.Directory} -o {artifactsDirectory}/{filenameWithoutExtensions}.zip"); | |
| } | |
| }); | |
| Target("default", DependsOn(Test, Publish)); | |
| RunTargetsAndExit(new string[]{}); | |
| return 0; | |
| } | |
| } | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment