├── .azure
├── pipelines
│ ├── ci-public.yml
│ └── ci.yml
└── templates
│ ├── jobs
│ └── default-build.yml
│ └── project-ci.yml
├── .config
└── tsaoptions.json
├── .editorconfig
├── .gitattributes
├── .github
└── ISSUE_TEMPLATE.md
├── .gitignore
├── BuildTools.sln
├── CONTRIBUTING.md
├── Directory.Build.props
├── Directory.Build.targets
├── LICENSE.txt
├── NuGet.Config
├── README.md
├── SECURITY.md
├── build.cmd
├── build.ps1
├── build.sh
├── build
├── dependencies.props
├── repo.props
├── repo.targets
├── sources.props
└── tasks
│ ├── RepoTasks.csproj
│ └── RepoTasks.tasks
├── docs
├── KoreBuild.md
├── Logging.md
├── PackageReferenceManagement.md
├── README.md
└── Signing.md
├── files
└── KoreBuild
│ ├── KoreBuild.Common.props
│ ├── KoreBuild.Common.targets
│ ├── KoreBuild.Overrides.targets
│ ├── KoreBuild.Verify.targets
│ ├── KoreBuild.proj
│ ├── KoreBuild.psd1
│ ├── KoreBuild.sh
│ ├── Project.Inspection.targets
│ ├── README.md
│ ├── config
│ └── sdk.version
│ ├── modules
│ ├── benchmarks
│ │ ├── Project.Inspection.targets
│ │ └── module.targets
│ ├── noop
│ │ └── module.targets
│ ├── projectbuild
│ │ └── module.targets
│ ├── sharedsources
│ │ ├── module.props
│ │ ├── module.targets
│ │ └── sharedsources.csproj
│ ├── solutionbuild
│ │ └── module.targets
│ ├── teamcity
│ │ └── module.targets
│ └── vstest
│ │ ├── Project.Inspection.targets
│ │ └── module.targets
│ ├── msbuild
│ └── KoreBuild.RepoTasks.Sdk
│ │ └── Sdk
│ │ ├── Sdk.props
│ │ └── Sdk.targets
│ └── scripts
│ ├── KoreBuild.psm1
│ ├── common.psm1
│ ├── common.sh
│ ├── dotnet-install.cmd
│ ├── dotnet-install.ps1
│ ├── dotnet-install.sh
│ ├── get-dotnet.sh
│ ├── get-netfx.sh
│ └── invoke-repository-build.sh
├── korebuild.json
├── modules
├── BuildTools.Tasks
│ ├── BuildTools.Tasks.csproj
│ ├── BuildTools.Tasks.props
│ ├── CreateSourceLink.cs
│ ├── GenerateFileFromTemplate.cs
│ ├── GenerateResxDesignerFiles.cs
│ ├── GenerateSvgBadge.cs
│ ├── GetAssemblyFileVersion.cs
│ ├── GetGitBranch.cs
│ ├── GetGitCommitHash.cs
│ ├── GetGitCommitInfo.cs
│ ├── Project.CSharp.Resx.targets
│ ├── Properties
│ │ └── InternalsVisibleTo.cs
│ ├── Publish.targets
│ ├── Run.cs
│ ├── RunBase.cs
│ ├── RunDotNet.cs
│ ├── SetEnvironmentVariable.cs
│ ├── UnzipArchive.cs
│ ├── UpdatePackageSource.cs
│ ├── Utilities
│ │ ├── FileHelpers.cs
│ │ ├── GitRepoInfo.cs
│ │ ├── IndentedTextWriter.cs
│ │ └── TextWriterExtensions.cs
│ ├── WaitForDebugger.cs
│ ├── ZipArchive.cs
│ ├── _._
│ ├── module.props
│ └── module.targets
├── BundledPackages
│ ├── BundledPackages.proj
│ └── TestConfig.txt
├── Directory.Build.props
├── KoreBuild.Tasks
│ ├── CheckPackageReferences.cs
│ ├── CodeSign.targets
│ ├── ComputeChecksum.cs
│ ├── DisableSkipStrongName.cs
│ ├── DownloadFile.cs
│ ├── DownloadNuGetPackages.cs
│ ├── EnableSkipStrongName.cs
│ ├── FindVisualStudio.cs
│ ├── GenerateDependenciesPropsFile.cs
│ ├── GeneratePackageVersionPropsFile.cs
│ ├── GetPathToFullMSBuild.cs
│ ├── GetToolsets.cs
│ ├── InstallDotNet.cs
│ ├── Internal
│ │ ├── DotNetAssetRequest.cs
│ │ ├── HashHelper.cs
│ │ ├── KoreBuildErrors.cs
│ │ ├── LoggingExtensions.cs
│ │ ├── MSBuildLogger.cs
│ │ ├── PackageInfo.cs
│ │ ├── ProjectModel
│ │ │ ├── DotNetCliReferenceInfo.cs
│ │ │ ├── PackageReferenceInfo.cs
│ │ │ ├── ProjectFrameworkInfo.cs
│ │ │ ├── ProjectInfo.cs
│ │ │ ├── ProjectInfoFactory.cs
│ │ │ ├── SolutionInfo.cs
│ │ │ └── SolutionInfoFactory.cs
│ │ └── SimplePackageInstaller.cs
│ ├── KoreBuild.Tasks.csproj
│ ├── PackNuSpec.cs
│ ├── Properties
│ │ └── InternalsVisibleTo.cs
│ ├── PushNuGetPackages.cs
│ ├── SkipStrongName
│ │ ├── AssembliesFile.cs
│ │ ├── AssemblySpecification.cs
│ │ ├── RegistrySection.cs
│ │ ├── Status.cs
│ │ ├── StrongNameConfiguration.cs
│ │ └── WindowsRegistry.cs
│ ├── SkipStrongNames.xml
│ ├── UpgradeDependencies.cs
│ ├── Utilities
│ │ ├── DependencyVersionsFile.cs
│ │ ├── EnvironmentHelper.cs
│ │ ├── KoreBuildVersion.cs
│ │ ├── PackageDownloadRequest.cs
│ │ ├── PackageDownloader.cs
│ │ ├── PackageVersionVariable.cs
│ │ ├── VsInstallation.cs
│ │ └── VsWhere.cs
│ ├── VerifyChecksum.cs
│ ├── module.props
│ └── module.targets
└── NuGetPackageVerifier
│ ├── NuGetPackageVerifier.proj
│ ├── console
│ ├── AssemblyAttributesData.cs
│ ├── AssemblyHelpers.cs
│ ├── CompositeRules
│ │ ├── AdxVerificationCompositeRule.cs
│ │ ├── CompositeRule.cs
│ │ ├── DefaultCompositeRule.cs
│ │ └── SigningVerificationCompositeRule.cs
│ ├── Constants.cs
│ ├── Extensions
│ │ └── PackageArchiveReaderExtensions.cs
│ ├── IPackageVerifierRule.cs
│ ├── IgnoreAssistanceMode.cs
│ ├── IssueIgnore.cs
│ ├── IssueProcessor.cs
│ ├── IssueReport.cs
│ ├── Logging
│ │ ├── IPackageVerifierLogger.cs
│ │ ├── LogLevel.cs
│ │ ├── PackageVerifierLogger.cs
│ │ ├── PackageVerifierLoggerExtensions.cs
│ │ └── TeamCityLogger.cs
│ ├── NuGetPackageVerifier.Console.csproj
│ ├── PackageAnalysisContext.cs
│ ├── PackageAnalyzer.cs
│ ├── PackageIssueFactory.cs
│ ├── PackageIssueLevel.cs
│ ├── PackageSet.cs
│ ├── PackageVerifierIssue.cs
│ ├── PackageVerifierOptions.cs
│ ├── Program.cs
│ ├── README.md
│ ├── Rules
│ │ ├── AssemblyAttributesDataHelper.cs
│ │ ├── AssemblyHasCommitHashAttributeRule.cs
│ │ ├── AssemblyHasCompanyAttributeRule.cs
│ │ ├── AssemblyHasCopyrightAttributeRule.cs
│ │ ├── AssemblyHasDescriptionAttributeRule.cs
│ │ ├── AssemblyHasDocumentFileRule.cs
│ │ ├── AssemblyHasNeutralResourcesLanguageAttributeRule.cs
│ │ ├── AssemblyHasProductAttributeRule.cs
│ │ ├── AssemblyHasServicingAttributeRule.cs
│ │ ├── AssemblyHasVersionAttributesRule.cs
│ │ ├── AssemblyIsBuiltInReleaseConfigurationRule.cs
│ │ ├── AssemblyStrongNameRule.cs
│ │ ├── AuthenticodeSigningRule.cs
│ │ ├── BuildItemsRule.cs
│ │ ├── DependenciesVersionRangeBoundsRule.cs
│ │ ├── DotNetCliToolPackageRule.cs
│ │ ├── DotNetToolPackageRule.cs
│ │ ├── PackageAuthorRule.cs
│ │ ├── PackageCopyrightRule.cs
│ │ ├── PackageOwnershipRule.cs
│ │ ├── PackageTypesRule.cs
│ │ ├── PackageVersionMatchesAssemblyVersionRule.cs
│ │ ├── PowerShellScriptIsSignedRule.cs
│ │ ├── PrereleaseDependenciesVersionRule.cs
│ │ ├── RequiredNuSpecInfoRule.cs
│ │ ├── RequiredPackageMetadataRule.cs
│ │ ├── SatellitePackageRule.cs
│ │ └── StrictSemanticVersionValidationRule.cs
│ ├── WinTrust.cs
│ └── runtimeconfig.template.json
│ ├── module.targets
│ └── msbuild
│ ├── NuGetPackageVerifier.Task.csproj
│ └── VerifyPackages.cs
├── push.cmd
├── push.ps1
├── scripts
├── PushNuGet.psm1
├── UpdateDependencyVersions.ps1
├── UploadKoreBuild.ps1
└── bootstrapper
│ ├── build.cmd
│ ├── build.sh
│ ├── run.cmd
│ ├── run.ps1
│ └── run.sh
├── shared
├── Microsoft.Extensions.CommandLineUtils.Sources
│ ├── CommandLine
│ │ ├── AnsiConsole.cs
│ │ ├── CommandArgument.cs
│ │ ├── CommandLineApplication.cs
│ │ ├── CommandOption.cs
│ │ ├── CommandOptionType.cs
│ │ └── CommandParsingException.cs
│ └── Utilities
│ │ ├── ArgumentEscaper.cs
│ │ └── DotNetMuxer.cs
└── Utilities
│ └── MSBuildListSplitter.cs
├── src
├── ApiCheck.Console
│ ├── ApiCheck.Console.csproj
│ ├── ApiListing
│ │ ├── ApiElement.cs
│ │ ├── ApiElementVisibility.cs
│ │ ├── ApiListing.cs
│ │ ├── ApiListingFilters.cs
│ │ ├── GenericParameterDescriptor.cs
│ │ ├── MemberDescriptor.cs
│ │ ├── MemberKind.cs
│ │ ├── ParameterDescriptor.cs
│ │ ├── ParameterDirection.cs
│ │ ├── TypeDescriptor.cs
│ │ └── TypeKind.cs
│ ├── ApiListingComparer.cs
│ ├── ApiListingGenerator.cs
│ ├── BreakingChange.cs
│ ├── ChangeKind.cs
│ ├── Loader
│ │ ├── AssemblyLoader.cs
│ │ ├── AssemblyNameComparer.cs
│ │ ├── CoreClrAssemblyLoader.cs
│ │ └── FullFrameworkAssemblyLoader.cs
│ ├── Microsoft.AspNetCore.BuildTools.ApiCheck.nuspec
│ ├── NuGet
│ │ ├── Package.cs
│ │ ├── PackageAssembly.cs
│ │ ├── PackageGraph.cs
│ │ ├── RuntimeDefinition.cs
│ │ ├── RuntimeGraph.Compatibility.cs
│ │ └── RuntimeGraph.cs
│ ├── Program.cs
│ ├── README.md
│ └── build
│ │ └── Microsoft.AspNetCore.BuildTools.ApiCheck.props
├── ApiCheck.Task
│ ├── ApiCheck.Task.csproj
│ ├── ApiCheckGenerateTask.cs
│ ├── ApiCheckTask.cs
│ └── ApiCheckTasksBase.cs
├── Internal.AspNetCore.Sdk
│ ├── Internal.AspNetCore.Sdk.csproj
│ ├── Internal.AspNetCore.Sdk.nuspec
│ ├── _._
│ ├── build
│ │ ├── ApiCheck.props
│ │ ├── ApiCheck.targets
│ │ ├── Common.props
│ │ ├── Common.targets
│ │ ├── DotNetTool.targets
│ │ ├── GenerateAssemblyInfo.targets
│ │ ├── Git.targets
│ │ ├── Internal.AspNetCore.Sdk.props
│ │ └── Internal.AspNetCore.Sdk.targets
│ └── buildMultiTargeting
│ │ ├── ApiCheck.targets
│ │ ├── Internal.AspNetCore.Sdk.props
│ │ └── Internal.AspNetCore.Sdk.targets
└── Internal.AspNetCore.SiteExtension.Sdk
│ ├── Internal.AspNetCore.SiteExtension.Sdk.csproj
│ ├── Internal.AspNetCore.SiteExtension.Sdk.nuspec
│ ├── TrimDeps.cs
│ ├── _._
│ ├── build
│ ├── Internal.AspNetCore.SiteExtension.Sdk.props
│ └── Internal.AspNetCore.SiteExtension.Sdk.targets
│ └── content
│ └── HostingStartup
│ ├── HostingStartup.csproj
│ └── Program.cs
├── test.ps1
├── test.sh
├── test
├── ApiCheck.Test
│ ├── ApiCheck.Test.csproj
│ ├── ApiListingComparerTests.cs
│ └── ApiListingGenerationTests.cs
├── ApiCheckBaseline.V1
│ ├── ApiCheckBaseline.V1.csproj
│ ├── ComparisonScenarios.cs
│ └── Scenarios.cs
├── ApiCheckBaseline.V2
│ ├── ApiCheckBaseline.V2.csproj
│ ├── ComparisonScenarios.cs
│ └── Scenarios.cs
├── ApiCheckForwardDestination
│ ├── ApiCheckForwardDestination.csproj
│ └── ComparisonScenarios.cs
├── BuildTools.Tasks.Tests
│ ├── BuildTools.Tasks.Tests.csproj
│ ├── CreateSourceLinkTest.cs
│ ├── GenerateFileFromTemplateTests.cs
│ ├── GenerateResxDesignerFilesTest.cs
│ ├── GetAssemblyFileVersionTest.cs
│ ├── GetGitCommitInfoTests.cs
│ ├── Resources
│ │ ├── SimpleGitRepo.zip
│ │ ├── SparseCheckout.zip
│ │ ├── Strings.Designer.cs.txt
│ │ ├── Strings.resx
│ │ ├── SubmoduleRepo.zip
│ │ ├── WorktreeRepo.zip
│ │ └── sampledata.json
│ ├── RunTaskTests.cs
│ ├── UnzipArchiveTest.cs
│ └── ZipArchiveTest.cs
├── Directory.Build.targets
├── KoreBuild.FunctionalTests
│ ├── GenerateTestProps.targets
│ ├── KoreBuild.FunctionalTests.csproj
│ ├── SimpleRepoTests.cs
│ └── Utilities
│ │ ├── RepoTestFixture.cs
│ │ └── TestApp.cs
├── KoreBuild.Tasks.Tests
│ ├── CheckPackageReferenceTests.cs
│ ├── ChecksumTests.cs
│ ├── DependencyVersionsFileTests.cs
│ ├── DownloadFileTests.cs
│ ├── DownloadNuGetPackagesTests.cs
│ ├── GenerateDependenciesPropsFileTests.cs
│ ├── GeneratePackageVersionPropsFileTests.cs
│ ├── GetToolsetsTests.cs
│ ├── InstallDotNetTests.cs
│ ├── KoreBuild.Tasks.Tests.csproj
│ ├── KoreBuildSettingsTest.cs
│ ├── MSBuildTestCollection.cs
│ ├── PackNuSpecTests.cs
│ ├── SolutionInfoFactoryTests.cs
│ ├── TestResources
│ │ └── lorem.bin
│ ├── UpgradeDependenciesTests.cs
│ └── VSWhereTests.cs
├── shared
│ └── MockEngine.cs
└── xunit.runner.json
├── testassets
├── RepoThatShouldFailToBuild
│ ├── Directory.Build.props
│ ├── Directory.Build.targets
│ ├── RepoThatShouldFailToBuild.sln
│ ├── build
│ │ └── dependencies.props
│ ├── korebuild.json
│ └── src
│ │ └── BadConsole
│ │ ├── BadConsole.csproj
│ │ └── Program.cs
├── RepoWithGlobalTool
│ ├── Directory.Build.props
│ ├── Directory.Build.targets
│ ├── RepoWithGlobalTool.sln
│ ├── build
│ │ └── dependencies.props
│ ├── korebuild.json
│ └── src
│ │ └── GlobalConsoleTool
│ │ ├── GlobalConsoleTool.csproj
│ │ └── Program.cs
└── SimpleRepo
│ ├── Directory.Build.props
│ ├── Directory.Build.targets
│ ├── NuGetPackageVerifier.json
│ ├── SimpleRepo.sln
│ ├── build
│ ├── Sample.Lineup.nuspec
│ ├── dependencies.props
│ ├── repo.props
│ ├── repo.targets
│ ├── sources.props
│ └── tasks
│ │ ├── RepoTasks.csproj
│ │ ├── RepoTasks.tasks
│ │ └── SayHello.cs
│ ├── korebuild.json
│ ├── samples
│ └── Simple.Sample
│ │ ├── Program.cs
│ │ └── Simple.Sample.csproj
│ ├── shared
│ └── Simple.Sources
│ │ └── Example.cs
│ ├── src
│ ├── Simple.CliTool
│ │ ├── Program.cs
│ │ └── Simple.CliTool.csproj
│ └── Simple.Lib
│ │ ├── Api.cs
│ │ ├── Simple.Lib.csproj
│ │ ├── baseline.netcore.json
│ │ ├── baseline.netframework.json
│ │ ├── breakingchanges.netcore.json
│ │ └── breakingchanges.netframework.json
│ ├── test
│ └── Simple.Test
│ │ ├── Simple.Test.csproj
│ │ └── UnitTest1.cs
│ └── version.props
├── tools
├── KoreBuild.Console
│ ├── Commands
│ │ ├── ApiBaselinesGenerateCommand.cs
│ │ ├── CommandBase.cs
│ │ ├── CommandContext.cs
│ │ ├── DependenciesGenerateCommand.cs
│ │ ├── DependenciesUpgradeCommand.cs
│ │ ├── DockerBuildCommand.cs
│ │ ├── DockerFiles
│ │ │ ├── .dockerignore
│ │ │ ├── jessie.dockerfile
│ │ │ └── winservercore.dockerfile
│ │ ├── InstallToolsCommand.cs
│ │ ├── MSBuildCommand.cs
│ │ ├── RootCommand.cs
│ │ └── SubCommandBase.cs
│ ├── KoreBuild.Console.csproj
│ ├── Program.cs
│ └── Reporter
│ │ ├── ConsoleReporter.cs
│ │ ├── IConsole.cs
│ │ ├── IReporter.cs
│ │ └── PhysicalConsole.cs
├── KoreBuildSettings.cs
└── korebuild.schema.json
└── version.props
/.azure/pipelines/ci-public.yml:
--------------------------------------------------------------------------------
1 | # Trigger builds for only pushes to some branches
2 | trigger:
3 | branches:
4 | include:
5 | - main
6 | - release/*
7 |
8 | # Trigger builds for PRs to any branch
9 | pr:
10 | branches:
11 | include:
12 | - '*'
13 |
14 | jobs:
15 | - template: ../templates/project-ci.yml
16 | parameters:
17 | # Ensures the alignment of branch name and deployment params
18 | buildArgs: '/warnaserror:BUILD1001'
19 | afterBuild:
20 | - task: PublishBuildArtifacts@1
21 | displayName: Upload KoreBuild artifact
22 | condition: and(succeeded(), eq(variables['BuildConfiguration'], 'Release'), eq(variables['AgentOsName'], 'Windows'), eq(variables['system.pullrequest.isfork'], false))
23 | inputs:
24 | pathtoPublish: artifacts/korebuild/
25 | artifactName: korebuild
26 | artifactType: Container
27 |
--------------------------------------------------------------------------------
/.azure/pipelines/ci.yml:
--------------------------------------------------------------------------------
1 | # Trigger builds for only pushes to some branches
2 | trigger:
3 | branches:
4 | include:
5 | - main
6 | - release/*
7 |
8 | # Trigger builds for PRs to any branch
9 | pr:
10 | branches:
11 | include:
12 | - '*'
13 |
14 | resources:
15 | repositories:
16 | # Repo: 1ESPipelineTemplates/1ESPipelineTemplates
17 | - repository: 1esPipelines
18 | type: git
19 | name: 1ESPipelineTemplates/1ESPipelineTemplates
20 | ref: refs/tags/release
21 |
22 | extends:
23 | template: v1/1ES.Official.PipelineTemplate.yml@1esPipelines
24 | parameters:
25 | sdl:
26 | policheck:
27 | enabled: true
28 | tsa:
29 | enabled: true
30 | sourceAnalysisPool:
31 | name: NetCore1ESPool-Svc-Internal
32 | image: windows.vs2022.amd64
33 | os: windows
34 | stages:
35 | - stage: build
36 | displayName: Build
37 | jobs:
38 | - template: .azure/templates/project-ci.yml@self
39 | parameters:
40 | # Ensures the alignment of branch name and deployment params
41 | buildArgs: '/warnaserror:BUILD1001'
42 | afterBuild:
43 | - task: 1ES.PublishPipelineArtifact@1
44 | displayName: Upload KoreBuild artifact
45 | condition: and(succeeded(), eq(variables['BuildConfiguration'], 'Release'), eq(variables['AgentOsName'], 'Windows'), eq(variables['system.pullrequest.isfork'], false))
46 | inputs:
47 | path: artifacts/korebuild/
48 | artifactName: korebuild
49 |
--------------------------------------------------------------------------------
/.config/tsaoptions.json:
--------------------------------------------------------------------------------
1 | {
2 | "areaPath": "DevDiv\\ASP.NET Core\\Policy Violations",
3 | "codebaseName": "BuildTools",
4 | "instanceUrl": "https://devdiv.visualstudio.com/",
5 | "iterationPath": "DevDiv",
6 | "notificationAliases": [
7 | "aspnetcore-build@microsoft.com"
8 | ],
9 | "projectName": "DEVDIV",
10 | "repositoryName": "BuildTools",
11 | "template": "TFSDEVDIV"
12 | }
13 |
--------------------------------------------------------------------------------
/.editorconfig:
--------------------------------------------------------------------------------
1 | ; EditorConfig to support per-solution formatting.
2 | ; Use the EditorConfig VS add-in to make this work.
3 | ; http://editorconfig.org/
4 |
5 | ; This is the default for the codeline.
6 | root = true
7 |
8 | [*]
9 | indent_style = space
10 | charset = utf-8
11 | trim_trailing_whitespace = true
12 | insert_final_newline = true
13 |
14 | [*.cs]
15 | indent_size = 4
16 | dotnet_sort_system_directives_first = true : warning
17 | csharp_style_var_when_type_is_apparent = true : warning
18 | csharp_style_var_for_built_in_types = true : warning
19 | csharp_style_var_elsewhere = true : warning
20 |
21 | [*.{xml,config,*proj,nuspec,props,resx,targets,yml,tasks}]
22 | indent_size = 2
23 |
24 | [*.json]
25 | indent_size = 2
26 |
27 | [*.{ps1,psm1}]
28 | indent_size = 4
29 |
30 | [*.sh]
31 | indent_size = 4
32 | end_of_line = lf
33 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
4 | # Custom for Visual Studio
5 | *.cs diff=csharp
6 |
7 | # Standard to msysgit
8 | *.doc diff=astextplain
9 | *.DOC diff=astextplain
10 | *.docx diff=astextplain
11 | *.DOCX diff=astextplain
12 | *.dot diff=astextplain
13 | *.DOT diff=astextplain
14 | *.pdf diff=astextplain
15 | *.PDF diff=astextplain
16 | *.rtf diff=astextplain
17 | *.RTF diff=astextplain
18 |
19 | *.sh eol=lf
20 | *.bin binary
21 | *.zip binary
22 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE.md:
--------------------------------------------------------------------------------
1 | This repository contains utilities used to build ASP.NET Core and Entity Framework Core.
2 |
3 | These utilities are not supported products of Microsoft and are intended for Microsoft use only.
4 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | bin
2 | obj
3 | *.suo
4 | *.user
5 | _ReSharper.*
6 | *.DS_Store
7 | *.userprefs
8 | *.pidb
9 | *.vspx
10 | *.psess
11 | *.log
12 | *.binlog
13 | packages
14 | target
15 | artifacts
16 | StyleCop.Cache
17 | node_modules
18 | *.snk
19 | .nuget/NuGet.exe
20 | project.lock.json
21 | .build
22 | .vs/
23 | .vscode/
24 | global.json
25 | launchSettings.json
26 | korebuild-lock.txt
27 | *.binlog
28 | .dotnet/
29 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | Contributing
2 | ======
3 |
4 | Information on contributing to this repo is in the [Contributing Guide](https://github.com/aspnet/AspNetCore/blob/main/CONTRIBUTING.md) in the AspNetCore repo.
5 |
--------------------------------------------------------------------------------
/Directory.Build.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | <_AspNetToolsSdkPath>$(MSBuildThisFileDirectory)src\Internal.AspNetCore.Sdk
9 | $(_AspNetToolsSdkPath)\build\Internal.AspNetCore.Sdk.targets
10 | $(_AspNetToolsSdkPath)\buildMultiTargeting\Internal.AspNetCore.Sdk.targets
11 | false
12 | false
13 | false
14 | false
15 | $(NoWarn);NU5105
16 | false
17 | true
18 | true
19 |
20 |
21 |
22 |
23 |
24 | https://github.com/aspnet/BuildTools
25 | git
26 | $(MSBuildThisFileDirectory)
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/Directory.Build.targets:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/LICENSE.txt:
--------------------------------------------------------------------------------
1 | Copyright (c) .NET Foundation. All rights reserved.
2 |
3 | Licensed under the Apache License, Version 2.0 (the "License"); you may not use
4 | these files except in compliance with the License. You may obtain a copy of the
5 | License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software distributed
10 | under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
11 | CONDITIONS OF ANY KIND, either express or implied. See the License for the
12 | specific language governing permissions and limitations under the License.
13 |
--------------------------------------------------------------------------------
/NuGet.Config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Build Tools
2 |
3 | Utilities used in the build system for projects that are used with ASP.NET Core and Entity Framework Core.
4 |
5 | This project is part of ASP.NET Core. You can find samples, documentation and getting started instructions for ASP.NET Core at the [AspNetCore](https://github.com/aspnet/AspNetCore) repo.
6 |
7 | ## Docs
8 |
9 | See [docs/README.md](./docs/README.md).
10 |
11 | ## Latest build
12 |
13 | Channel | Latest Build
14 | ---------------|:---------------
15 | main | ![badge][main-badge]
16 | release/2.1 | ![badge][rel-2.1-badge]
17 |
18 | [main-badge]: https://dotnetbuilds.blob.core.windows.net/buildtools/korebuild/channels/main/badge.svg
19 | [rel-2.1-badge]: https://dotnetbuilds.blob.core.windows.net/buildtools/korebuild/channels/release/2.1/badge.svg
20 |
21 | This tool contains build scripts, console tools, MSBuild targets, and other settings required to build ASP.NET Core.
22 |
23 | ## Local testing
24 |
25 | To test changes to this project locally we recommend you do:
26 |
27 | ```ps1
28 | ./test.ps1 -Command $CommandToTest -RepoPath C:\repo\to\test\against\
29 | ```
30 |
--------------------------------------------------------------------------------
/SECURITY.md:
--------------------------------------------------------------------------------
1 | # Security Policy
2 |
3 | ## Supported Versions
4 |
5 | The .NET Core and ASP.NET Core support policy, including supported versions can be found at the [.NET Core Support Policy Page](https://dotnet.microsoft.com/platform/support/policy/dotnet-core).
6 |
7 | ## Reporting a Vulnerability
8 |
9 | Security issues and bugs should be reported privately to the Microsoft Security Response Center (MSRC), either by emailing secure@microsoft.com or via the portal at https://msrc.microsoft.com.
10 | You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your
11 | original message. Further information, including the MSRC PGP key, can be found in the [MSRC Report an Issue FAQ](https://www.microsoft.com/en-us/msrc/faqs-report-an-issue).
12 |
13 | Reports via MSRC may qualify for the .NET Core Bug Bounty. Details of the .NET Core Bug Bounty including terms and conditions are at [https://aka.ms/corebounty](https://aka.ms/corebounty).
14 |
15 | Please do not open issues for anything you think might have a security implication.
16 |
--------------------------------------------------------------------------------
/build.cmd:
--------------------------------------------------------------------------------
1 | @ECHO OFF
2 | PowerShell -NoProfile -NoLogo -ExecutionPolicy unrestricted -Command "[System.Threading.Thread]::CurrentThread.CurrentCulture = ''; [System.Threading.Thread]::CurrentThread.CurrentUICulture = '';& '%~dp0build.ps1' %*; exit $LASTEXITCODE"
--------------------------------------------------------------------------------
/build/repo.props:
--------------------------------------------------------------------------------
1 |
2 |
3 | true
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/build/sources.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | $(DotNetRestoreSources)
6 |
7 | $(RestoreSources);
8 | https://dotnetfeed.blob.core.windows.net/dotnet-core/index.json;
9 | https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public/nuget/v3/index.json;
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/build/tasks/RepoTasks.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | netcoreapp2.1
6 | net46
7 | $(DefineConstants);BuildTools
8 | $(NoWarn);NU1603
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/build/tasks/RepoTasks.tasks:
--------------------------------------------------------------------------------
1 |
2 |
3 | <_RepoTaskAssembly>$(MSBuildThisFileDirectory)bin\publish\RepoTasks.dll
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/docs/Logging.md:
--------------------------------------------------------------------------------
1 | Logging
2 | -------
3 |
4 | KoreBuild produces log files to $(RepositoryRoot)/artifacts/logs. The following log formats can be used:
5 |
6 | ## Binary Logger
7 |
8 | Using `build.cmd -Verbose` will produce a binary log file to artifacts/logs/msbuild.binlog.
9 |
10 | See for details.
11 |
12 | ## TeamCity Logger
13 |
14 | KoreBuild can produce log messages for TeamCity by using .
15 |
16 | To configure this,
17 |
18 | 1. Download the logger from JetBrains. https://github.com/JetBrains/TeamCity.MSBuild.Logger#download
19 | 2. Install this on CI agents.
20 | 3. Set the environment variable `KOREBUILD_TEAMCITY_LOGGER` to the file path of TeamCity.MSBuild.Logger.dll on CI agents.
21 |
--------------------------------------------------------------------------------
/docs/README.md:
--------------------------------------------------------------------------------
1 | Intro to BuildTools
2 | -------------------
3 |
4 | This repo contains console tools, MSBuild tasks, and targets used to build ASP.NET Core.
5 | This document is a high-level overview of how these build tools work.
6 |
7 | ## Step-by-step how "build.cmd" works
8 |
9 | Most KoreBuild repositories will have an identical build.cmd script in the top-level repo directory. This script can be found in [scripts/bootstrapper/build.cmd][build-cmd]. These are the steps the script takes. (The same steps apply to build.sh for Linux builds.)
10 |
11 | 1. [build.cmd][build-cmd] invokes "[run.ps1][run-ps1] default-build".
12 | 1. [run.ps1][run-ps1] downloads and extracts KoreBuild as a zip file
13 | 1. [run.ps1][run-ps1] imports the [KoreBuild.psm1][korebuild-psm1] file which contains a few functions for invoking commands. It then invokes `Invoke-KoreBuildCommand 'default-build'`
14 | 1. [KoreBuild.psm1][korebuild-psm1] defines the `Invoke-KoreBuildCommand` function. This function will
15 | 1. Ensure dotnet is installed
16 | 1. Build `$RepoRoot/build/tasks/RepoTasks.csproj` if it exists
17 | 1. Starts MSBuild by calling `dotnet msbuild KoreBuild.proj`
18 | 1. [KoreBuild.proj][korebuild-proj] is the entry point for building the entire repo in an MSBuild process. By default, this project will restore, compile, package, and test \*.sln files. It has some extensibility points to repos can extend. See [./KoreBuild.md](./KoreBuild.md).
19 |
20 |
21 | [build-cmd]: ../scripts/bootstrapper/build.cmd
22 | [run-ps1]: ../scripts/bootstrapper/run.ps1
23 | [korebuild-psm1]: ../files/KoreBuild/scripts/KoreBuild.psm1
24 | [korebuild-proj]: ../files/KoreBuild/KoreBuild.proj
25 | [korebuild-common]: ../files/KoreBuild/KoreBuild.proj
26 |
--------------------------------------------------------------------------------
/files/KoreBuild/KoreBuild.Overrides.targets:
--------------------------------------------------------------------------------
1 |
2 |
3 | Package;ShowTestSkippedMessage
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/files/KoreBuild/KoreBuild.proj:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/files/KoreBuild/KoreBuild.psd1:
--------------------------------------------------------------------------------
1 | @{
2 | GUID = 'e572c360-3572-4558-821f-4bed8511a5e2'
3 | RootModule = 'scripts/KoreBuild.psm1'
4 | Author = 'ASP.NET Core'
5 | CompanyName = 'Microsoft'
6 | Copyright = '.NET Foundation'
7 | ModuleVersion = '0.1'
8 | Description = 'Functions for using KoreBuild'
9 | PowerShellVersion = '4.0'
10 | FunctionsToExport = @('Set-KoreBuildSettings', 'Invoke-KoreBuildCommand')
11 | AliasesToExport = @('')
12 | VariablesToExport = @('')
13 | }
14 |
--------------------------------------------------------------------------------
/files/KoreBuild/README.md:
--------------------------------------------------------------------------------
1 | KoreBuild
2 | =========
3 |
4 | This is a set of tools for building a repository with MSBuild. It is designed for use with ASP.NET Core projects.
5 |
6 | Layout
7 | ------
8 |
9 | File/Folder | Purpose
10 | ----------------------------|--------------
11 | .version | Contains the current version of korebuild. For diagnostics and logging.
12 | KoreBuild.psd1 | PowerShell module for executing korebuild.
13 | KoreBuild.sh | Bash module for executing korebuild. (Should be `source`'d).
14 | config/ | Contains configuration data.
15 | scripts/ | Bash/PowerShell scripts
16 | modules/ | Extensions to the KoreBuild lifecycle.
17 |
--------------------------------------------------------------------------------
/files/KoreBuild/config/sdk.version:
--------------------------------------------------------------------------------
1 | 2.1.526
2 |
--------------------------------------------------------------------------------
/files/KoreBuild/modules/benchmarks/Project.Inspection.targets:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | GetTargetPath
5 |
6 |
7 |
8 |
9 |
10 | $(TargetFramework)
11 |
12 |
13 |
14 |
15 | <_TargetFramework Include="$(TargetFrameworks)" />
16 |
17 |
18 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/files/KoreBuild/modules/benchmarks/module.targets:
--------------------------------------------------------------------------------
1 |
2 |
3 |
10 |
11 | $(TestDependsOn);ValidateBenchmarks
12 |
13 |
14 |
15 |
16 | <_InspectionTargetsFile>$(MSBuildThisFileDirectory)Project.Inspection.targets
17 |
18 |
19 |
25 |
26 |
27 |
28 |
29 |
32 |
33 |
35 |
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/files/KoreBuild/modules/noop/module.targets:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 | ______
10 | ( Moo! )
11 | ------
12 | \ ^__^
13 | \ (oo)\_______
14 | (__)\ )\/\
15 | ||----w |
16 | || ||
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/files/KoreBuild/modules/sharedsources/module.props:
--------------------------------------------------------------------------------
1 |
2 |
3 | $(RepositoryRoot)shared/
4 |
5 |
6 |
7 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/files/KoreBuild/modules/teamcity/module.targets:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/files/KoreBuild/msbuild/KoreBuild.RepoTasks.Sdk/Sdk/Sdk.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | true
5 | true
6 | true
7 |
8 |
9 | library
10 |
11 |
15 | 9.0.1
16 | 4.6.1
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/files/KoreBuild/scripts/common.psm1:
--------------------------------------------------------------------------------
1 | function __exec($_cmd) {
2 | $cmdName = [IO.Path]::GetFileName($_cmd)
3 |
4 | Write-Host -ForegroundColor Cyan ">>> $cmdName $args"
5 | $originalErrorPref = $ErrorActionPreference
6 | $ErrorActionPreference = 'Continue'
7 | & $_cmd @args
8 | $exitCode = $LASTEXITCODE
9 | $ErrorActionPreference = $originalErrorPref
10 | if ($exitCode -ne 0) {
11 | throw "$cmdName failed with exit code: $exitCode"
12 | }
13 | else {
14 | Write-Verbose "<<< $cmdName [$exitCode]"
15 | }
16 | }
17 |
18 | function Join-Paths($path, $childPaths) {
19 | $childPaths | ForEach-Object { $path = Join-Path $path $_ }
20 | return $path
21 | }
22 |
--------------------------------------------------------------------------------
/files/KoreBuild/scripts/dotnet-install.cmd:
--------------------------------------------------------------------------------
1 | @ECHO OFF
2 | SET Args=%*
3 | SET Args=%Args:"='%
4 | PowerShell -NoProfile -NoLogo -ExecutionPolicy unrestricted -Command "[System.Threading.Thread]::CurrentThread.CurrentCulture = ''; [System.Threading.Thread]::CurrentThread.CurrentUICulture = '';& '%~dp0dotnet-install.ps1' %Args%; exit $LASTEXITCODE"
5 |
--------------------------------------------------------------------------------
/files/KoreBuild/scripts/get-netfx.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | __script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
4 |
5 | # flow failures thru piped commands, disallow unrecognized variables, and exit on first failure
6 | set -euo pipefail
7 |
8 | source "$__script_dir/common.sh"
9 |
10 | if ! __machine_has 'tar'; then
11 | __error 'Required command not available: tar'
12 | exit 1
13 | fi
14 |
15 | if [ "${1:-}" = "--verbose" ]; then
16 | __is_verbose=true
17 | shift
18 | fi
19 |
20 | netfx_version=$1
21 | tools_source=$2
22 | install_dir=$3
23 | remote_path="$tools_source/netfx/$netfx_version/netfx.$netfx_version.tar.gz"
24 |
25 | if [ -d "$install_dir" ]; then
26 | echo -e "${GRAY}Using cached .NET Framework reference assemblies from ${install_dir}${RESET}"
27 | exit 0
28 | fi
29 |
30 | tmpfile="$(mktemp)"
31 | tmpdir="$(mktemp -d)"
32 | rm "$tmpfile" >/dev/null 2>&1 || :
33 | echo "Downloading .NET Framework reference assemblies"
34 | __fetch "$remote_path" "$tmpfile"
35 | mkdir -p "$tmpdir"
36 | tar -C "$tmpdir" -xzf "$tmpfile"
37 | rm "$tmpfile" || :
38 |
39 | mkdir -p "$(dirname "$install_dir")"
40 | if [ ! -d "$install_dir" ]; then
41 | echo "Extracting .NET Framework reference assemblies to $install_dir"
42 | mv "$tmpdir" "$install_dir"
43 | else
44 | __verbose 'Not copying into place. Looks like someone else already beat us to it.'
45 | rm -rf "$tmpdir" || :
46 | fi
47 |
--------------------------------------------------------------------------------
/korebuild.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "./tools/korebuild.schema.json",
3 | "channel": "release/2.1"
4 | }
5 |
--------------------------------------------------------------------------------
/modules/BuildTools.Tasks/BuildTools.Tasks.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | $(DefineConstants);BuildTools
6 | MSBuild tasks. This package is intended for Microsoft use only
7 | netcoreapp2.1;net46
8 | Microsoft.AspNetCore.BuildTools
9 | Internal.AspNetCore.BuildTools.Tasks
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/modules/BuildTools.Tasks/GetAssemblyFileVersion.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using System;
5 | using Microsoft.Build.Framework;
6 | using Microsoft.Build.Utilities;
7 |
8 | namespace Microsoft.AspNetCore.BuildTools
9 | {
10 | #if SDK
11 | public class Sdk_GetAssemblyFileVersion : Task
12 | #elif BuildTools
13 | public class GetAssemblyFileVersion : Task
14 | #else
15 | #error This must be built either for an SDK or for BuildTools
16 | #endif
17 | {
18 | [Required]
19 | public string AssemblyVersion { get; set; }
20 |
21 | [Required]
22 | public int AssemblyRevision { get; set; }
23 |
24 | [Output]
25 | public string AssemblyFileVersion { get; set; }
26 |
27 | public override bool Execute()
28 | {
29 | if (!Version.TryParse(AssemblyVersion, out var assemblyVersionValue))
30 | {
31 | Log.LogError("Invalid value '{0}' for {1}.", AssemblyVersion, nameof(AssemblyVersion));
32 | return false;
33 | }
34 |
35 | var assemblyFileVersionValue = assemblyVersionValue;
36 | if (assemblyFileVersionValue.Revision <= 0)
37 | {
38 | assemblyFileVersionValue = new Version(
39 | assemblyFileVersionValue.Major,
40 | assemblyFileVersionValue.Minor,
41 | assemblyFileVersionValue.Build,
42 | AssemblyRevision);
43 | }
44 |
45 | AssemblyFileVersion = assemblyFileVersionValue.ToString();
46 | return true;
47 | }
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/modules/BuildTools.Tasks/Project.CSharp.Resx.targets:
--------------------------------------------------------------------------------
1 |
11 |
12 |
13 | Resx
14 |
15 |
16 |
17 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/modules/BuildTools.Tasks/Properties/InternalsVisibleTo.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using System.Runtime.CompilerServices;
5 |
6 | [assembly: InternalsVisibleTo("BuildTools.Tasks.Tests")]
7 |
--------------------------------------------------------------------------------
/modules/BuildTools.Tasks/Publish.targets:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 | <_TargetFramework Remove="@(_TargetFramework)" />
10 | <_TargetFramework Include="$(TargetFrameworks)" />
11 |
12 |
13 |
14 |
15 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/modules/BuildTools.Tasks/Run.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using Microsoft.Build.Framework;
5 | using Microsoft.Build.Utilities;
6 |
7 | namespace Microsoft.AspNetCore.BuildTools
8 | {
9 | ///
10 | /// A task that runs a process without piping output into the logger.
11 | /// See for more arguments.
12 | ///
13 | #if SDK
14 | public class Sdk_Run
15 | #elif BuildTools
16 | public class Run
17 | #else
18 | #error This must be built either for an SDK or for BuildTools
19 | #endif
20 | : RunBase
21 | {
22 | ///
23 | /// The executable to run. Can be a file path or a command for an executable on the system PATH.
24 | ///
25 | [Required]
26 | public string FileName { get; set; }
27 |
28 | protected override string ToolName => FileName;
29 |
30 | protected override string GenerateFullPathToTool()
31 | {
32 | return FileName;
33 | }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/modules/BuildTools.Tasks/RunDotNet.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using Microsoft.Extensions.CommandLineUtils;
5 |
6 | namespace Microsoft.AspNetCore.BuildTools
7 | {
8 | ///
9 | /// A task that runs a dotnet command without piping output into the logger.
10 | /// See for more arguments.
11 | ///
12 | #if SDK
13 | public class Sdk_RunDotNet
14 | #elif BuildTools
15 | public class RunDotNet
16 | #else
17 | #error This must be built either for an SDK or for BuildTools
18 | #endif
19 | : RunBase
20 | {
21 | protected override string ToolName => "dotnet";
22 |
23 | protected override string GenerateFullPathToTool()
24 | #if NET46
25 | => "dotnet";
26 | #else
27 | => DotNetMuxer.MuxerPathOrDefault();
28 | #endif
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/modules/BuildTools.Tasks/SetEnvironmentVariable.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using System;
5 | using Microsoft.Build.Framework;
6 | using Microsoft.Build.Utilities;
7 |
8 | namespace Microsoft.AspNetCore.BuildTools
9 | {
10 | #if SDK
11 | public class Sdk_SetEnvironmentVariable : Task
12 | #elif BuildTools
13 | public class SetEnvironmentVariable : Task
14 | #else
15 | #error This must be built either for an SDK or for BuildTools
16 | #endif
17 | {
18 | [Required]
19 | public string Variable { get; set; }
20 |
21 | [Required]
22 | public string Value { get; set; }
23 |
24 | public override bool Execute()
25 | {
26 | if (string.IsNullOrEmpty(Variable))
27 | {
28 | Log.LogError($"{nameof(Variable)} cannot be null or an empty string");
29 | return false;
30 | }
31 |
32 | var expandedValue = Environment.ExpandEnvironmentVariables(Value);
33 |
34 | Log.LogMessage("Setting environment variable '{0}' to '{1}'", Variable, expandedValue);
35 |
36 | Environment.SetEnvironmentVariable(Variable, expandedValue);
37 |
38 | return true;
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/modules/BuildTools.Tasks/Utilities/FileHelpers.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using System.IO;
5 |
6 | namespace Microsoft.AspNetCore.BuildTools.Utilities
7 | {
8 | internal class FileHelpers
9 | {
10 | public static string EnsureTrailingSlash(string path)
11 | => !HasTrailingSlash(path)
12 | ? path + Path.DirectorySeparatorChar
13 | : path;
14 |
15 | public static bool HasTrailingSlash(string path)
16 | => !string.IsNullOrEmpty(path) && (path[path.Length - 1] == Path.DirectorySeparatorChar ||
17 | path[path.Length - 1] == Path.AltDirectorySeparatorChar);
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/modules/BuildTools.Tasks/Utilities/IndentedTextWriter.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using System;
5 | using System.IO;
6 | using System.Text;
7 |
8 | namespace Microsoft.AspNetCore.BuildTools.Utilities
9 | {
10 | internal class IndentedTextWriter : TextWriter
11 | {
12 | private readonly TextWriter _wrapped;
13 | private readonly string _spaces;
14 |
15 | public IndentedTextWriter(TextWriter wrapped, int indentSpaces)
16 | {
17 | _wrapped = wrapped;
18 | _spaces = new String(' ', indentSpaces);
19 | }
20 |
21 | public override Encoding Encoding => _wrapped.Encoding;
22 |
23 | public override void Write(char value)
24 | => _wrapped.Write(value);
25 |
26 | public override void WriteLine(string line)
27 | {
28 | _wrapped.Write(_spaces);
29 | _wrapped.WriteLine(line);
30 | }
31 |
32 | protected override void Dispose(bool disposing)
33 | {
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/modules/BuildTools.Tasks/Utilities/TextWriterExtensions.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using Microsoft.AspNetCore.BuildTools.Utilities;
5 |
6 | namespace System.IO
7 | {
8 | internal static class TextWriterExtensions
9 | {
10 | public static IndentedTextWriter Indent(this TextWriter writer, int spaces = 4)
11 | => new IndentedTextWriter(writer, spaces);
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/modules/BuildTools.Tasks/WaitForDebugger.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using System.Diagnostics;
5 | using System.Threading;
6 | using Microsoft.Build.Framework;
7 | using Microsoft.Build.Utilities;
8 |
9 | namespace Microsoft.AspNetCore.BuildTools
10 | {
11 | #if SDK
12 | public class Sdk_WaitForDebugger : Task, ICancelableTask
13 | #elif BuildTools
14 | public class WaitForDebugger : Task
15 | #else
16 | #error This must be built either for an SDK or for BuildTools
17 | #endif
18 | {
19 | private bool _canceled;
20 |
21 | public void Cancel()
22 | {
23 | _canceled = true;
24 | }
25 |
26 | public override bool Execute()
27 | {
28 | Log.LogMessage(MessageImportance.High, $"Waiting for debugger. Process ID: {Process.GetCurrentProcess().Id}");
29 |
30 | // 30 seconds
31 | var maxTimeout = 30 * 1000;
32 | var step = 150;
33 |
34 | while (!Debugger.IsAttached && maxTimeout > 0 && !_canceled)
35 | {
36 | Thread.Sleep(step);
37 | maxTimeout -= step;
38 | }
39 |
40 | if (!Debugger.IsAttached && !_canceled)
41 | {
42 | Log.LogMessage(MessageImportance.High, "Waiting for debugger timed out. Continuing execution.");
43 | }
44 |
45 | return true;
46 | }
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/modules/BuildTools.Tasks/_._:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aspnet/BuildTools/d35d7d63ceecbf0d937b2f0d06f041ca61c14f2c/modules/BuildTools.Tasks/_._
--------------------------------------------------------------------------------
/modules/BuildTools.Tasks/module.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | <_BuildToolsAssembly Condition="'$(MSBuildRuntimeType)' == 'core' ">$(MSBuildThisFileDirectory)netcoreapp2.1\Internal.AspNetCore.BuildTools.Tasks.dll
5 | <_BuildToolsAssembly Condition="'$(MSBuildRuntimeType)' != 'core' ">$(MSBuildThisFileDirectory)net46\Internal.AspNetCore.BuildTools.Tasks.dll
6 | <_BuildTasksPrefix>
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/modules/BundledPackages/TestConfig.txt:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/modules/Directory.Build.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | false
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/modules/KoreBuild.Tasks/ComputeChecksum.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using Microsoft.Build.Framework;
5 |
6 | namespace KoreBuild.Tasks
7 | {
8 | ///
9 | /// Computes the checksum for a single file.
10 | ///
11 | public class ComputeChecksum : Microsoft.Build.Utilities.Task
12 | {
13 | ///
14 | /// The file path.
15 | ///
16 | [Required]
17 | public string File { get; set; }
18 |
19 | ///
20 | /// The algorithm. Allowed values: SHA256, SHA384, SHA512.
21 | ///
22 | public string Algorithm { get; set; } = "SHA256";
23 |
24 | ///
25 | /// The hash.
26 | ///
27 | [Output]
28 | public string Hash { get; set; }
29 |
30 | public override bool Execute()
31 | {
32 | Hash = HashHelper.GetFileHash(Algorithm, File);
33 |
34 | return true;
35 | }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/modules/KoreBuild.Tasks/GetPathToFullMSBuild.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using System.Runtime.InteropServices;
5 | using KoreBuild.Tasks.Utilities;
6 | using Microsoft.Build.Framework;
7 |
8 | namespace KoreBuild.Tasks
9 | {
10 | ///
11 | /// Finds toolset information as listed in korebuild.json
12 | ///
13 | public class GetPathToFullMSBuild : Microsoft.Build.Utilities.Task
14 | {
15 | ///
16 | /// The path to MSBuild.exe (x86).
17 | ///
18 | [Output]
19 | public string MSBuildx86Path { get; set; }
20 |
21 | public override bool Execute()
22 | {
23 | if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
24 | {
25 | Log.LogError("Full MSBuild is not available on non-Windows.");
26 | return false;
27 | }
28 |
29 | var vs = VsWhere.FindLatestInstallation(includePrerelease: true, Log);
30 |
31 | if (vs == null)
32 | {
33 | Log.LogError($"Could not find an installation of Visual Studio.");
34 | return false;
35 | }
36 |
37 | MSBuildx86Path = vs.GetMSBuildx86SubPath();
38 |
39 | return !Log.HasLoggedErrors;
40 | }
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/modules/KoreBuild.Tasks/Internal/HashHelper.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using System;
5 | using System.IO;
6 | using System.Security.Cryptography;
7 | using System.Text;
8 |
9 | namespace KoreBuild.Tasks
10 | {
11 | internal class HashHelper
12 | {
13 | public static string GetFileHash(string algorithmName, string filePath)
14 | {
15 | byte[] hash;
16 | using (var stream = File.OpenRead(filePath))
17 | {
18 | HashAlgorithm algorithm;
19 | switch (algorithmName.ToUpperInvariant())
20 | {
21 | case "SHA256":
22 | algorithm = new SHA256Managed();
23 | break;
24 | case "SHA384":
25 | algorithm = new SHA384Managed();
26 | break;
27 | case "SHA512":
28 | algorithm = new SHA512Managed();
29 | break;
30 | default:
31 | throw new ArgumentOutOfRangeException($"Unsupported hash algoritm {algorithmName}", nameof(algorithm));
32 | }
33 | hash = algorithm.ComputeHash(stream);
34 | }
35 |
36 | var sb = new StringBuilder();
37 | foreach (var b in hash)
38 | {
39 | sb.AppendFormat("{0:X2}", b);
40 | }
41 |
42 | return sb.ToString();
43 | }
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/modules/KoreBuild.Tasks/Internal/KoreBuildErrors.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | namespace KoreBuild.Tasks
5 | {
6 | public static class KoreBuildErrors
7 | {
8 | public const string Prefix = "KRB";
9 |
10 | // Warnings
11 | public const int DotNetAssetVersionIsFloating = 2000;
12 | public const int RepoVersionDoesNotMatchProjectVersion = 2001;
13 | public const int RepoPackageVersionDoesNotMatchProjectPackageVersion = 2002;
14 | public const int DuplicatePackageReference = 2003;
15 |
16 | // NuGet errors
17 | public const int InvalidNuspecFile = 4001;
18 | public const int ConflictingPackageReferenceVersions = 4002;
19 | public const int DependenciesFileDoesNotExist = 4003;
20 | public const int PackageVersionNotFoundInLineup = 4004;
21 | public const int PackageRefHasLiteralVersion = 4005;
22 | public const int VariableNotFoundInDependenciesPropsFile = 4006;
23 | public const int PackageRefHasFloatingVersion = 4007;
24 | public const int PackageRefPropertyGroupNotFound = 4008;
25 | public const int PackageReferenceDoesNotHaveVersion = 4009;
26 | public const int InvalidPackageVersion = 4010;
27 | public const int NuspecMissingFilesNode = 4011;
28 | public const int InvalidPackagePathMetadata = 4012;
29 |
30 | // Other errors
31 | public const int MissingArtifactType = 5001;
32 |
33 | // not used in code, but reserved for MSBuild targets
34 | public const int ArtifactInfoMismatch = 5002;
35 | public const int FilesToSignMismatchedWithArtifactInfo = 5003;
36 | public const int FilesToSignMissingCertInfo = 5004;
37 | public const int PackageSymbolsAreNotPortable = 5005;
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/modules/KoreBuild.Tasks/Internal/LoggingExtensions.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using Microsoft.Build.Utilities;
5 |
6 | namespace KoreBuild.Tasks
7 | {
8 | public static class LoggingExtensions
9 | {
10 | public static void LogKoreBuildError(this TaskLoggingHelper logger, int code, string message, params object[] messageArgs)
11 | => LogKoreBuildError(logger, null, 0, code, message, messageArgs: messageArgs);
12 |
13 | public static void LogKoreBuildError(this TaskLoggingHelper logger, string filename, int code, string message, params object[] messageArgs)
14 | => LogKoreBuildError(logger, null, 0, code, message, messageArgs: messageArgs);
15 |
16 | public static void LogKoreBuildError(this TaskLoggingHelper logger, string filename, int lineNumber, int code, string message, params object[] messageArgs)
17 | {
18 | logger.LogError(null, KoreBuildErrors.Prefix + code, null, filename, lineNumber, 0, 0, 0, message, messageArgs: messageArgs);
19 | }
20 |
21 | public static void LogKoreBuildWarning(this TaskLoggingHelper logger, int code, string message, params object[] messageArgs)
22 | => LogKoreBuildWarning(logger, null, code, message, messageArgs: messageArgs);
23 |
24 | public static void LogKoreBuildWarning(this TaskLoggingHelper logger, string filename, int code, string message, params object[] messageArgs)
25 | {
26 | logger.LogWarning(null, KoreBuildErrors.Prefix + code, null, filename, 0, 0, 0, 0, message, messageArgs: messageArgs);
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/modules/KoreBuild.Tasks/Internal/PackageInfo.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using NuGet.Packaging.Core;
5 |
6 | namespace KoreBuild.Tasks.Internal
7 | {
8 | public class PackageInfo
9 | {
10 | public PackageIdentity Identity { get; set; }
11 |
12 | public string PackagePath { get; set; }
13 |
14 | public override string ToString()
15 | {
16 | return Identity.ToString();
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/modules/KoreBuild.Tasks/Internal/ProjectModel/DotNetCliReferenceInfo.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using System;
5 |
6 | namespace KoreBuild.Tasks.ProjectModel
7 | {
8 | internal class DotNetCliReferenceInfo
9 | {
10 | public DotNetCliReferenceInfo(string id, string version)
11 | {
12 | if (string.IsNullOrEmpty(id))
13 | {
14 | throw new ArgumentException(nameof(id));
15 | }
16 |
17 | Id = id;
18 | Version = version;
19 | }
20 |
21 | public string Id { get; }
22 | public string Version { get; }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/modules/KoreBuild.Tasks/Internal/ProjectModel/PackageReferenceInfo.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using System;
5 | using System.Collections.Generic;
6 |
7 | namespace KoreBuild.Tasks.ProjectModel
8 | {
9 | internal class PackageReferenceInfo
10 | {
11 | public PackageReferenceInfo(string id, string version, bool isImplicitlyDefined, IReadOnlyList noWarn)
12 | {
13 | if (string.IsNullOrEmpty(id))
14 | {
15 | throw new ArgumentException(nameof(id));
16 | }
17 |
18 | Id = id;
19 | Version = version;
20 | IsImplicitlyDefined = isImplicitlyDefined;
21 | NoWarn = noWarn;
22 | }
23 |
24 | public string Id { get; }
25 | public string Version { get; }
26 | public bool IsImplicitlyDefined { get; }
27 | public IReadOnlyList NoWarn { get; }
28 | public ProjectInfo Project { get; internal set; }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/modules/KoreBuild.Tasks/Internal/ProjectModel/ProjectFrameworkInfo.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using System;
5 | using System.Collections.Generic;
6 | using System.Linq;
7 | using NuGet.Frameworks;
8 |
9 | namespace KoreBuild.Tasks.ProjectModel
10 | {
11 | internal class ProjectFrameworkInfo
12 | {
13 | public ProjectFrameworkInfo(NuGetFramework targetFramework, IReadOnlyDictionary dependencies)
14 | {
15 | TargetFramework = targetFramework ?? throw new ArgumentNullException(nameof(targetFramework));
16 | Dependencies = dependencies ?? throw new ArgumentNullException(nameof(dependencies));
17 | }
18 |
19 | public NuGetFramework TargetFramework { get; }
20 | public IReadOnlyDictionary Dependencies { get; }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/modules/KoreBuild.Tasks/Internal/ProjectModel/ProjectInfo.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using System;
5 | using System.Collections.Generic;
6 | using System.IO;
7 | using System.Linq;
8 |
9 | namespace KoreBuild.Tasks.ProjectModel
10 | {
11 | internal class ProjectInfo
12 | {
13 | public ProjectInfo(string fullPath,
14 | string projectExtensionsPath,
15 | IReadOnlyList frameworks,
16 | IReadOnlyList tools)
17 | {
18 | if (!Path.IsPathRooted(fullPath))
19 | {
20 | throw new ArgumentException("Path must be absolute", nameof(fullPath));
21 | }
22 |
23 | Frameworks = frameworks ?? throw new ArgumentNullException(nameof(frameworks));
24 | Tools = tools ?? throw new ArgumentNullException(nameof(tools));
25 |
26 | FullPath = fullPath;
27 | FileName = Path.GetFileName(fullPath);
28 | Directory = Path.GetDirectoryName(FullPath);
29 | ProjectExtensionsPath = projectExtensionsPath ?? Path.Combine(Directory, "obj");
30 |
31 | foreach (var dep in frameworks.SelectMany(f => f.Dependencies))
32 | {
33 | dep.Value.Project = this;
34 | }
35 | }
36 |
37 | public string FullPath { get; }
38 | public string FileName { get; }
39 | public string ProjectExtensionsPath { get; }
40 | public string Directory { get; }
41 |
42 | public IReadOnlyList Frameworks { get; }
43 | public IReadOnlyList Tools { get; }
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/modules/KoreBuild.Tasks/Internal/ProjectModel/SolutionInfo.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using System;
5 | using System.Collections.Generic;
6 |
7 | namespace KoreBuild.Tasks.ProjectModel
8 | {
9 | internal class SolutionInfo
10 | {
11 | public SolutionInfo(string fullPath, IReadOnlyList projects)
12 | {
13 | if (string.IsNullOrEmpty(fullPath))
14 | {
15 | throw new ArgumentException(nameof(fullPath));
16 | }
17 |
18 | FullPath = fullPath;
19 | Projects = projects ?? throw new ArgumentNullException(nameof(projects));
20 | }
21 |
22 | public string FullPath { get; }
23 |
24 | public IReadOnlyList Projects { get; }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/modules/KoreBuild.Tasks/Properties/InternalsVisibleTo.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using System.Runtime.CompilerServices;
5 |
6 | [assembly: InternalsVisibleTo("KoreBuild.Tasks.Tests")]
7 | [assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")]
8 |
--------------------------------------------------------------------------------
/modules/KoreBuild.Tasks/SkipStrongName/AssemblySpecification.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
2 |
3 | namespace KoreBuild.Tasks.SkipStrongNames
4 | {
5 | internal class AssemblySpecification
6 | {
7 | public string Name { get; set; }
8 |
9 | public string PublicKeyToken { get; set; }
10 |
11 | public override string ToString()
12 | {
13 | return Name + "," + PublicKeyToken;
14 | }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/modules/KoreBuild.Tasks/SkipStrongName/RegistrySection.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
2 |
3 | namespace KoreBuild.Tasks.SkipStrongNames
4 | {
5 | public enum RegistrySection
6 | {
7 | Native,
8 | Windows32OnWindows64
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/modules/KoreBuild.Tasks/SkipStrongName/Status.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
2 |
3 | namespace KoreBuild.Tasks.SkipStrongNames
4 | {
5 | public enum Status
6 | {
7 | Disabled,
8 | Enabled,
9 | PartiallyEnabled,
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/modules/KoreBuild.Tasks/SkipStrongNames.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/modules/KoreBuild.Tasks/Utilities/EnvironmentHelper.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using System;
5 | using System.IO;
6 | using System.Linq;
7 | using System.Runtime.InteropServices;
8 |
9 | namespace KoreBuild.Tasks.Utilities
10 | {
11 | internal class EnvironmentHelper
12 | {
13 | private static string[] _searchPaths;
14 | private static string[] _executableExtensions;
15 |
16 | static EnvironmentHelper()
17 | {
18 | _searchPaths = Environment.GetEnvironmentVariable("PATH")
19 | .Split(Path.PathSeparator)
20 | .Select(p => p.Trim('"'))
21 | .ToArray();
22 |
23 | _executableExtensions = RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
24 | ? Environment.GetEnvironmentVariable("PATHEXT").Split(';').Select(e => e.ToLower().Trim('"')).ToArray()
25 | : new [] { string.Empty };
26 | }
27 |
28 | public static string GetCommandOnPath(string exeName)
29 | {
30 | return _searchPaths.Join(
31 | _executableExtensions,
32 | p => true,
33 | e => true,
34 | (p, e) => Path.Combine(p, exeName + e))
35 | .FirstOrDefault(File.Exists);
36 | }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/modules/KoreBuild.Tasks/Utilities/KoreBuildVersion.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using System.IO;
5 | using System.Reflection;
6 |
7 | namespace KoreBuild.Tasks
8 | {
9 | internal class KoreBuildVersion
10 | {
11 | private static string _version;
12 |
13 | public static string Current
14 | {
15 | get
16 | {
17 | if (_version == null)
18 | {
19 | var assembly = typeof(KoreBuildVersion).Assembly.GetCustomAttribute();
20 | if (assembly != null)
21 | {
22 | _version = assembly.InformationalVersion;
23 | }
24 | }
25 |
26 | return _version;
27 | }
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/modules/KoreBuild.Tasks/Utilities/PackageDownloadRequest.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using System.Collections.Generic;
5 | using NuGet.Packaging.Core;
6 |
7 | namespace KoreBuild.Tasks.Utilities
8 | {
9 | public class PackageDownloadRequest
10 | {
11 | public PackageIdentity Identity { get; set; }
12 | public string OutputPath { get; set; }
13 | public IReadOnlyList Sources { get; set; }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/modules/KoreBuild.Tasks/Utilities/PackageVersionVariable.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using System;
5 | using Microsoft.Build.Construction;
6 |
7 | namespace KoreBuild.Tasks.Utilities
8 | {
9 | public class PackageVersionVariable
10 | {
11 | private readonly ProjectPropertyElement _element;
12 |
13 | public PackageVersionVariable(ProjectPropertyElement element, bool isReadOnly)
14 | : this(element, element.Value?.Trim(), isReadOnly)
15 | {
16 | }
17 |
18 | public PackageVersionVariable(ProjectPropertyElement element, string version, bool isReadOnly)
19 | {
20 | _element = element ?? throw new ArgumentNullException(nameof(element));
21 | IsReadOnly = isReadOnly;
22 | Name = element.Name.ToString();
23 | Version = version ?? string.Empty;
24 | }
25 |
26 | public string Name { get; }
27 |
28 | public string Version
29 | {
30 | get => _element.Value;
31 | private set => _element.Value = value;
32 | }
33 |
34 | public bool IsReadOnly { get; private set; }
35 |
36 | public void UpdateVersion(string version)
37 | {
38 | if (IsReadOnly)
39 | {
40 | throw new InvalidOperationException("You cannot updated a pinned package version variable automatically");
41 | }
42 |
43 | Version = version;
44 | }
45 |
46 | public void AddToGroup(ProjectPropertyGroupElement group)
47 | {
48 | group.AppendChild(_element);
49 | }
50 |
51 | public void SetLabel(string label)
52 | {
53 | _element.Label = label;
54 | }
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/modules/KoreBuild.Tasks/Utilities/VsInstallation.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using System.IO;
5 | using System.Linq;
6 |
7 | namespace KoreBuild.Tasks.Utilities
8 | {
9 | ///
10 | /// A DTO that is deserialized from the output of 'vswhere.exe -format json'
11 | ///
12 | internal class VsInstallation
13 | {
14 | private static readonly string[] Versions = { "Current", "15.0", "16.0" };
15 |
16 | public string DisplayName { get; set; }
17 | public string InstallationPath { get; set; }
18 |
19 | // Add methods for additional info inferred from the vswhere.exe output.
20 | public string GetMSBuildx86SubPath()
21 | {
22 | return Versions
23 | .Select(v => Path.Combine(InstallationPath, "MSBuild", v, "Bin", "MSBuild.exe"))
24 | .FirstOrDefault(File.Exists);
25 | }
26 |
27 | public string GetMSBuildx64SubPath()
28 | {
29 | return Versions
30 | .Select(v => Path.Combine(InstallationPath, "MSBuild", v, "Bin", "amd64", "MSBuild.exe"))
31 | .FirstOrDefault(File.Exists);
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/modules/KoreBuild.Tasks/VerifyChecksum.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using System;
5 | using Microsoft.Build.Framework;
6 |
7 | namespace KoreBuild.Tasks
8 | {
9 | ///
10 | /// Verify the checksum for a single file.
11 | ///
12 | public class VerifyChecksum : Microsoft.Build.Utilities.Task
13 | {
14 | ///
15 | /// The file path.
16 | ///
17 | [Required]
18 | public string File { get; set; }
19 |
20 | ///
21 | /// The algorithm. Allowed values: SHA256, SHA384, SHA512.
22 | ///
23 | public string Algorithm { get; set; } = "SHA256";
24 |
25 | ///
26 | /// The hash.
27 | ///
28 | [Required]
29 | public string Hash { get; set; }
30 |
31 | public override bool Execute()
32 | {
33 | var actualHash = HashHelper.GetFileHash(Algorithm, File);
34 |
35 | if (!actualHash.Equals(Hash, StringComparison.OrdinalIgnoreCase))
36 | {
37 | Log.LogError($"Checksum mismatch. Expected {File} to have {Algorithm} checksum of {Hash}, but it was {actualHash}");
38 | return false;
39 | }
40 |
41 | return true;
42 | }
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/modules/NuGetPackageVerifier/NuGetPackageVerifier.proj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/modules/NuGetPackageVerifier/console/AssemblyAttributesData.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using Mono.Cecil;
5 | using Mono.Collections.Generic;
6 |
7 | namespace NuGetPackageVerifier
8 | {
9 | public class AssemblyAttributesData
10 | {
11 | public AssemblyNameDefinition AssemblyName { get; set; }
12 |
13 | public Collection AssemblyAttributes { get; set; }
14 |
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/modules/NuGetPackageVerifier/console/AssemblyHelpers.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using System;
5 | using System.IO;
6 | using System.Runtime.Loader;
7 |
8 | namespace NuGetPackageVerifier
9 | {
10 | public class AssemblyHelpers
11 | {
12 | public static bool IsAssemblyManaged(string assemblyPath)
13 | {
14 | // From http://msdn.microsoft.com/en-us/library/ms173100.aspx
15 | try
16 | {
17 | AssemblyLoadContext.GetAssemblyName(assemblyPath);
18 | return true;
19 | }
20 | catch (FileNotFoundException)
21 | {
22 | // The file cannot be found
23 | }
24 | catch (BadImageFormatException)
25 | {
26 | // The file is not an assembly
27 | }
28 | catch (FileLoadException)
29 | {
30 | // The assembly has already been loaded
31 | }
32 | return false;
33 | }
34 | }
35 | }
--------------------------------------------------------------------------------
/modules/NuGetPackageVerifier/console/CompositeRules/AdxVerificationCompositeRule.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using System.Collections.Generic;
5 |
6 | namespace NuGetPackageVerifier.Rules
7 | {
8 | public class AdxVerificationCompositeRule : IPackageVerifierRule
9 | {
10 | private readonly IPackageVerifierRule[] _rules = {
11 | new DefaultCompositeRule()
12 | };
13 |
14 | public IEnumerable Validate(PackageAnalysisContext context)
15 | {
16 | foreach (var rule in _rules)
17 | {
18 | foreach (var issue in rule.Validate(context))
19 | {
20 | yield return issue;
21 | }
22 | }
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/modules/NuGetPackageVerifier/console/CompositeRules/CompositeRule.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using System.Collections.Generic;
5 |
6 | namespace NuGetPackageVerifier
7 | {
8 | public abstract class CompositeRule : IPackageVerifierRule
9 | {
10 | protected abstract IPackageVerifierRule[] Rules { get; }
11 |
12 | public IEnumerable GetRules()
13 | {
14 | var rules = new List();
15 | foreach (var rule in Rules)
16 | {
17 | if (rule is CompositeRule compositeRule)
18 | {
19 | rules.AddRange(compositeRule.GetRules());
20 | }
21 | else
22 | {
23 | rules.Add(rule);
24 | }
25 | }
26 |
27 | return rules;
28 | }
29 |
30 | public virtual IEnumerable Validate(PackageAnalysisContext context)
31 | {
32 | foreach (var rule in Rules)
33 | {
34 | foreach (var issue in rule.Validate(context))
35 | {
36 | yield return issue;
37 | }
38 | }
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/modules/NuGetPackageVerifier/console/CompositeRules/DefaultCompositeRule.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using System.Collections.Generic;
5 |
6 | namespace NuGetPackageVerifier.Rules
7 | {
8 | public class DefaultCompositeRule : CompositeRule
9 | {
10 | protected override IPackageVerifierRule[] Rules => new IPackageVerifierRule[]
11 | {
12 | new AssemblyHasCompanyAttributeRule(),
13 | new AssemblyHasCopyrightAttributeRule(),
14 | new AssemblyHasDocumentFileRule(),
15 | new AssemblyHasDescriptionAttributeRule(),
16 | new AssemblyHasNeutralResourcesLanguageAttributeRule(),
17 | new AssemblyHasProductAttributeRule(),
18 | new AssemblyHasServicingAttributeRule(),
19 | new AssemblyHasVersionAttributesRule(),
20 | new AssemblyStrongNameRule(),
21 | new PackageCopyrightRule(),
22 | new PackageAuthorRule(),
23 | new RequiredPackageMetadataRule(),
24 | new RequiredNuSpecInfoRule(),
25 | new SatellitePackageRule(),
26 | new StrictSemanticVersionValidationRule(),
27 | new DependenciesVersionRangeBoundsRule(),
28 | new DotNetCliToolPackageRule(),
29 | new DotNetToolPackageRule(),
30 | new PackageTypesRule(),
31 | new PrereleaseDependenciesVersionRule(),
32 | new PackageVersionMatchesAssemblyVersionRule(),
33 | new BuildItemsRule(),
34 | };
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/modules/NuGetPackageVerifier/console/CompositeRules/SigningVerificationCompositeRule.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using System.Collections.Generic;
5 |
6 | namespace NuGetPackageVerifier.Rules
7 | {
8 | public class SigningVerificationCompositeRule : CompositeRule
9 | {
10 | protected override IPackageVerifierRule[] Rules => new IPackageVerifierRule[]
11 | {
12 | new AssemblyHasCommitHashAttributeRule(),
13 | new AssemblyIsBuiltInReleaseConfigurationRule(),
14 | new AuthenticodeSigningRule(),
15 | new PowerShellScriptIsSignedRule(),
16 | new PackageOwnershipRule(),
17 | };
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/modules/NuGetPackageVerifier/console/Constants.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using NuGet.Packaging.Core;
5 |
6 | namespace NuGetPackageVerifier
7 | {
8 | public class Constants
9 | {
10 | public static PackageType DotNetTool = new PackageType("DotnetTool", PackageType.EmptyVersion);
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/modules/NuGetPackageVerifier/console/IPackageVerifierRule.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using System.Collections.Generic;
5 |
6 | namespace NuGetPackageVerifier
7 | {
8 | public interface IPackageVerifierRule
9 | {
10 | IEnumerable Validate(PackageAnalysisContext context);
11 | }
12 | }
13 |
14 |
--------------------------------------------------------------------------------
/modules/NuGetPackageVerifier/console/IgnoreAssistanceMode.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | namespace NuGetPackageVerifier
5 | {
6 | public enum IgnoreAssistanceMode
7 | {
8 | ///
9 | /// Don't assist with creating verification ignores.
10 | ///
11 | None,
12 |
13 | ///
14 | /// Show ignore data for new (non-ignored) verification issues.
15 | ///
16 | ShowNew,
17 |
18 | ///
19 | /// Show ignore data for all verification issues (include those already ignored).
20 | ///
21 | ShowAll,
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/modules/NuGetPackageVerifier/console/IssueIgnore.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | namespace NuGetPackageVerifier
5 | {
6 | public class IssueIgnore
7 | {
8 | public string PackageId { get; set; }
9 | public string IssueId { get; set; }
10 | public string Instance { get; set; }
11 | public string Justification { get; set; }
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/modules/NuGetPackageVerifier/console/IssueReport.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using NuGetPackageVerifier.Logging;
5 |
6 | namespace NuGetPackageVerifier
7 | {
8 | public class IssueReport
9 | {
10 | public IssueReport(PackageVerifierIssue packageIssue, bool ignore, string ignoreJustification)
11 | {
12 | PackageIssue = packageIssue;
13 | IssueLevel = ignore ? LogLevel.Info : packageIssue.Level == PackageIssueLevel.Warning ? LogLevel.Warning : LogLevel.Error;
14 | IgnoreJustification = ignoreJustification;
15 | }
16 |
17 | public PackageVerifierIssue PackageIssue { get; }
18 |
19 | public LogLevel IssueLevel { get; }
20 |
21 | public string IgnoreJustification { get; set; }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/modules/NuGetPackageVerifier/console/Logging/IPackageVerifierLogger.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | namespace NuGetPackageVerifier.Logging
5 | {
6 | public interface IPackageVerifierLogger
7 | {
8 | void Log(LogLevel logLevel, string message);
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/modules/NuGetPackageVerifier/console/Logging/LogLevel.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | namespace NuGetPackageVerifier.Logging
5 | {
6 | public enum LogLevel
7 | {
8 | Info,
9 | Normal,
10 | Warning,
11 | Error,
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/modules/NuGetPackageVerifier/console/Logging/PackageVerifierLogger.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using System;
5 |
6 | namespace NuGetPackageVerifier.Logging
7 | {
8 | public class PackageVerifierLogger : IPackageVerifierLogger
9 | {
10 | private readonly bool _hideInfoLogs;
11 |
12 | public PackageVerifierLogger(bool hideInfoLogs)
13 | {
14 | _hideInfoLogs = hideInfoLogs;
15 | }
16 |
17 | public void Log(LogLevel logLevel, string message)
18 | {
19 | if (_hideInfoLogs && logLevel == LogLevel.Info)
20 | {
21 | return;
22 | }
23 |
24 | var output = Console.Out;
25 | ConsoleColor foreColor;
26 | switch (logLevel)
27 | {
28 | case LogLevel.Error:
29 | output = Console.Error;
30 | foreColor = ConsoleColor.Red;
31 | break;
32 |
33 | case LogLevel.Warning:
34 | foreColor = ConsoleColor.Yellow;
35 | break;
36 |
37 | case LogLevel.Normal:
38 | foreColor = ConsoleColor.Gray;
39 | break;
40 | default:
41 | foreColor = ConsoleColor.White;
42 | break;
43 | }
44 |
45 | Console.ForegroundColor = foreColor;
46 | output.WriteLine("{0}: {1}", logLevel.ToString().ToUpperInvariant(), message);
47 | Console.ForegroundColor = ConsoleColor.Gray;
48 | }
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/modules/NuGetPackageVerifier/console/Logging/PackageVerifierLoggerExtensions.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | namespace NuGetPackageVerifier.Logging
5 | {
6 | public static class PackageVerifierLoggerExtensions
7 | {
8 | public static void Log(this IPackageVerifierLogger logger, LogLevel logLevel, string message, params object[] args)
9 | {
10 | logger.Log(logLevel, string.Format(message, args));
11 | }
12 |
13 | public static void LogWarning(this IPackageVerifierLogger logger, string message, params object[] args)
14 | {
15 | logger.Log(LogLevel.Warning, message, args);
16 | }
17 |
18 | public static void LogError(this IPackageVerifierLogger logger, string message, params object[] args)
19 | {
20 | logger.Log(LogLevel.Error, message, args);
21 | }
22 |
23 | public static void LogInfo(this IPackageVerifierLogger logger, string message, params object[] args)
24 | {
25 | logger.Log(LogLevel.Info, message, args);
26 | }
27 |
28 | public static void LogNormal(this IPackageVerifierLogger logger, string message, params object[] args)
29 | {
30 | logger.Log(LogLevel.Normal, message, args);
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/modules/NuGetPackageVerifier/console/Logging/TeamCityLogger.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using System;
5 |
6 | namespace NuGetPackageVerifier.Logging
7 | {
8 | public class TeamCityLogger : IPackageVerifierLogger
9 | {
10 | private readonly bool _hideInfoLogs;
11 |
12 | public TeamCityLogger(bool hideInfoLogs)
13 | {
14 | _hideInfoLogs = hideInfoLogs;
15 | }
16 |
17 | public void Log(LogLevel logLevel, string message)
18 | {
19 | if (_hideInfoLogs && logLevel == LogLevel.Info)
20 | {
21 | return;
22 | }
23 |
24 | string status;
25 | switch (logLevel)
26 | {
27 | case LogLevel.Error:
28 | status = "ERROR";
29 | break;
30 | case LogLevel.Warning:
31 | status = "WARNING";
32 | break;
33 | case LogLevel.Normal:
34 | status = "NORMAL";
35 | break;
36 | default:
37 | status = "NORMAL";
38 | break;
39 | }
40 |
41 | message = message
42 | .Replace("|", "||")
43 | .Replace("'", "|'")
44 | .Replace("\r", "|r")
45 | .Replace("\n", "|n")
46 | .Replace("]", "|]");
47 |
48 | Console.WriteLine($"##teamcity[message text='{message}' status='{status}']");
49 | }
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/modules/NuGetPackageVerifier/console/NuGetPackageVerifier.Console.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Verifies Asp.Net Core NuGet packages.
5 | netcoreapp2.1
6 | NuGetPackageVerifier
7 | NuGetPackageVerifier
8 | exe
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/modules/NuGetPackageVerifier/console/PackageAnalysisContext.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using System;
5 | using System.Collections.Generic;
6 | using System.IO;
7 | using NuGet.Packaging;
8 | using NuGetPackageVerifier.Logging;
9 |
10 | namespace NuGetPackageVerifier
11 | {
12 | public class PackageAnalysisContext : IDisposable
13 | {
14 | private PackageArchiveReader _reader;
15 |
16 | public FileInfo PackageFileInfo { get; set; }
17 | public IPackageMetadata Metadata { get; set; }
18 | public PackageVerifierOptions Options { get; set; }
19 | public IPackageVerifierLogger Logger { get; set; }
20 | public PackageArchiveReader PackageReader => _reader ?? (_reader = new PackageArchiveReader(PackageFileInfo.FullName));
21 |
22 | public IDictionary AssemblyData { get; } = new Dictionary();
23 |
24 | public virtual void Dispose()
25 | {
26 | _reader?.Dispose();
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/modules/NuGetPackageVerifier/console/PackageAnalyzer.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using System.Collections.Generic;
5 | using System.Linq;
6 |
7 | namespace NuGetPackageVerifier
8 | {
9 | public class PackageAnalyzer
10 | {
11 | public IList Rules { get; } = new List();
12 |
13 | public IEnumerable AnalyzePackage(PackageAnalysisContext context)
14 | {
15 | var packageIssues = new List();
16 | foreach (var rule in Rules)
17 | {
18 | var issues = rule.Validate(context).ToList();
19 | packageIssues = packageIssues.Concat(issues).ToList();
20 | }
21 |
22 | return packageIssues;
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/modules/NuGetPackageVerifier/console/PackageIssueLevel.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | namespace NuGetPackageVerifier
5 | {
6 | public enum PackageIssueLevel
7 | {
8 | Warning,
9 | Error
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/modules/NuGetPackageVerifier/console/PackageSet.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using System.Collections.Generic;
5 |
6 | namespace NuGetPackageVerifier
7 | {
8 | public class PackageSet
9 | {
10 | // Class names of rules to use
11 | public string[] Rules { get; set; }
12 |
13 | // List of packages(key), each with a set of rules to ignore(key), each with a set of instances(key),
14 | // each of which has a justification(value)
15 | public IDictionary Packages { get; set; }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/modules/NuGetPackageVerifier/console/PackageVerifierIssue.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | namespace NuGetPackageVerifier
5 | {
6 | public class PackageVerifierIssue
7 | {
8 | public PackageVerifierIssue(string issueId, string issue, PackageIssueLevel level)
9 | : this(issueId, instance: null, issue: issue, level: level)
10 | {
11 | }
12 |
13 | public PackageVerifierIssue(string issueId, string instance, string issue, PackageIssueLevel level)
14 | {
15 | Instance = instance;
16 | IssueId = issueId;
17 | Issue = issue;
18 | Level = level;
19 | }
20 |
21 | public PackageIssueLevel Level
22 | {
23 | get;
24 | }
25 |
26 | public string Issue
27 | {
28 | get;
29 | }
30 |
31 | public string IssueId
32 | {
33 | get;
34 | }
35 |
36 | public string Instance
37 | {
38 | get; set;
39 | }
40 |
41 | public override string ToString() => $"{IssueId} @ {Instance}: {Level.ToString().ToUpperInvariant()}: {Issue}";
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/modules/NuGetPackageVerifier/console/PackageVerifierOptions.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using System;
5 | using System.Collections.Generic;
6 |
7 | namespace NuGetPackageVerifier
8 | {
9 | public class PackageVerifierOptions
10 | {
11 | // ignored warnings (with a justification)
12 | // key = issueid
13 | // values =
14 | public IDictionary> Exclusions { get; set; }
15 | = new Dictionary>(StringComparer.OrdinalIgnoreCase);
16 |
17 | public IList PackageTypes { get; set; }
18 | }
19 | }
--------------------------------------------------------------------------------
/modules/NuGetPackageVerifier/console/README.md:
--------------------------------------------------------------------------------
1 | NuGetPackageVerifier
2 | --------------------
3 |
4 | Internal tool for verifying a nupkg meets certain requirements.
5 |
6 | NuGetPackageVerifier.json schema
7 | ```js
8 | {
9 | "$ruleSetName$": { /* if $ruleSetName$ == 'Default', the ruleset is run for packages not listed in any other ruleset */
10 | "rules": [ "$ruleNameToRun$" ],
11 | "packages": {
12 | "$packageId$": {
13 | "exclusions": {
14 | "$ISSUE_ID$": {
15 | "$file$": "$justification$"
16 | }
17 | },
18 | "packageTypes": [ "$packageType$" ] /* Optional. For validating http://docs.nuget.org/create/package-types */
19 | }
20 | }
21 | }
22 | }
23 | ```
--------------------------------------------------------------------------------
/modules/NuGetPackageVerifier/console/Rules/AssemblyHasCommitHashAttributeRule.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using System;
5 | using System.Collections.Generic;
6 | using System.IO;
7 | using System.Linq;
8 | using System.Reflection;
9 | using Mono.Cecil;
10 | using Mono.Collections.Generic;
11 |
12 | namespace NuGetPackageVerifier.Rules
13 | {
14 | public class AssemblyHasCommitHashAttributeRule : IPackageVerifierRule
15 | {
16 | public IEnumerable Validate(PackageAnalysisContext context)
17 | {
18 | AssemblyAttributesDataHelper.SetAssemblyAttributesData(context);
19 | foreach (var assemblyData in context.AssemblyData)
20 | {
21 | var fileName = Path.GetFileNameWithoutExtension(assemblyData.Key);
22 | var isSourcesPackage = fileName.EndsWith(".Sources", StringComparison.OrdinalIgnoreCase);
23 | if (!isSourcesPackage && !HasCommitHashInMetadataAttribute(assemblyData.Value.AssemblyAttributes))
24 | {
25 | yield return PackageIssueFactory.AssemblyMissingHashAttribute(assemblyData.Key);
26 | }
27 | }
28 | }
29 |
30 | private static bool HasCommitHashInMetadataAttribute(Collection assemblyAttributes)
31 | {
32 | var hashAttribute = assemblyAttributes
33 | .SingleOrDefault(a =>
34 | a.AttributeType.FullName == typeof(AssemblyMetadataAttribute).FullName
35 | && a.ConstructorArguments.Count == 2
36 | && a.ConstructorArguments[0].Value as string == "CommitHash"
37 | && !string.IsNullOrEmpty(a.ConstructorArguments[1].Value as string));
38 |
39 | return hashAttribute != null;
40 | }
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/modules/NuGetPackageVerifier/console/Rules/AssemblyHasCompanyAttributeRule.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using System.Collections.Generic;
5 | using System.Linq;
6 | using System.Reflection;
7 | using Mono.Cecil;
8 | using Mono.Collections.Generic;
9 |
10 | namespace NuGetPackageVerifier.Rules
11 | {
12 | public class AssemblyHasCompanyAttributeRule : IPackageVerifierRule
13 | {
14 | public IEnumerable Validate(PackageAnalysisContext context)
15 | {
16 | AssemblyAttributesDataHelper.SetAssemblyAttributesData(context);
17 | foreach (var assemblyData in context.AssemblyData)
18 | {
19 | if (!HasCompanyAttribute(assemblyData.Value.AssemblyAttributes))
20 | {
21 | yield return PackageIssueFactory.AssemblyMissingCompanyAttribute(assemblyData.Key);
22 | }
23 | }
24 | }
25 |
26 | private static bool HasCompanyAttribute(Collection asmAttrs)
27 | {
28 | var foundAttr = asmAttrs.SingleOrDefault(attr => attr.AttributeType.FullName == typeof(AssemblyCompanyAttribute).FullName);
29 | if (foundAttr == null)
30 | {
31 | return false;
32 | }
33 | var foundAttrArg = foundAttr.ConstructorArguments.SingleOrDefault();
34 | var attrValue = foundAttrArg.Value as string;
35 |
36 | return !string.IsNullOrEmpty(attrValue);
37 | }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/modules/NuGetPackageVerifier/console/Rules/AssemblyHasCopyrightAttributeRule.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using System.Collections.Generic;
5 | using System.Linq;
6 | using System.Reflection;
7 | using Mono.Cecil;
8 | using Mono.Collections.Generic;
9 |
10 | namespace NuGetPackageVerifier.Rules
11 | {
12 | public class AssemblyHasCopyrightAttributeRule : IPackageVerifierRule
13 | {
14 | public IEnumerable Validate(PackageAnalysisContext context)
15 | {
16 | AssemblyAttributesDataHelper.SetAssemblyAttributesData(context);
17 | foreach (var assemblyData in context.AssemblyData)
18 | {
19 | if (!HasCopyrightAttribute(assemblyData.Value.AssemblyAttributes))
20 | {
21 | yield return PackageIssueFactory.AssemblyMissingCopyrightAttribute(assemblyData.Key);
22 | }
23 | }
24 | }
25 |
26 | private static bool HasCopyrightAttribute(Collection asmAttrs)
27 | {
28 | var foundAttr = asmAttrs.SingleOrDefault(attr => attr.AttributeType.FullName == typeof(AssemblyCopyrightAttribute).FullName);
29 | if (foundAttr == null)
30 | {
31 | return false;
32 | }
33 | var foundAttrArg = foundAttr.ConstructorArguments.SingleOrDefault();
34 | var attrValue = foundAttrArg.Value as string;
35 |
36 | return !string.IsNullOrEmpty(attrValue);
37 | }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/modules/NuGetPackageVerifier/console/Rules/AssemblyHasDescriptionAttributeRule.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using System.Collections.Generic;
5 | using System.Linq;
6 | using System.Reflection;
7 | using Mono.Cecil;
8 | using Mono.Collections.Generic;
9 |
10 | namespace NuGetPackageVerifier.Rules
11 | {
12 | public class AssemblyHasDescriptionAttributeRule : IPackageVerifierRule
13 | {
14 | public IEnumerable Validate(PackageAnalysisContext context)
15 | {
16 | AssemblyAttributesDataHelper.SetAssemblyAttributesData(context);
17 | foreach (var assemblyData in context.AssemblyData)
18 | {
19 | if (!HasDescriptionAttribute(assemblyData.Value.AssemblyAttributes))
20 | {
21 | yield return PackageIssueFactory.AssemblyMissingDescriptionAttribute(assemblyData.Key);
22 | }
23 | }
24 | }
25 |
26 | private static bool HasDescriptionAttribute(Collection asmAttrs)
27 | {
28 | var foundAttr = asmAttrs.SingleOrDefault(attr => attr.AttributeType.FullName == typeof(AssemblyDescriptionAttribute).FullName);
29 | if (foundAttr == null)
30 | {
31 | return false;
32 | }
33 | var foundAttrArg = foundAttr.ConstructorArguments.SingleOrDefault();
34 | var attrValue = foundAttrArg.Value as string;
35 |
36 | return !string.IsNullOrEmpty(attrValue);
37 | }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/modules/NuGetPackageVerifier/console/Rules/AssemblyHasProductAttributeRule.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using System.Collections.Generic;
5 | using System.Linq;
6 | using System.Reflection;
7 | using Mono.Cecil;
8 | using Mono.Collections.Generic;
9 |
10 | namespace NuGetPackageVerifier.Rules
11 | {
12 | public class AssemblyHasProductAttributeRule : IPackageVerifierRule
13 | {
14 | public IEnumerable Validate(PackageAnalysisContext context)
15 | {
16 | AssemblyAttributesDataHelper.SetAssemblyAttributesData(context);
17 | foreach (var assemblyData in context.AssemblyData)
18 | {
19 | if (!HasProductAttribute(assemblyData.Value.AssemblyAttributes))
20 | {
21 | yield return PackageIssueFactory.AssemblyMissingProductAttribute(assemblyData.Key);
22 | }
23 | }
24 | }
25 |
26 | private static bool HasProductAttribute(Collection asmAttrs)
27 | {
28 | var foundAttr = asmAttrs.SingleOrDefault(attr => attr.AttributeType.FullName == typeof(AssemblyProductAttribute).FullName);
29 | if (foundAttr == null)
30 | {
31 | return false;
32 | }
33 | var foundAttrArg = foundAttr.ConstructorArguments.SingleOrDefault();
34 | var attrValue = foundAttrArg.Value as string;
35 |
36 | return !string.IsNullOrEmpty(attrValue);
37 | }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/modules/NuGetPackageVerifier/console/Rules/AssemblyHasServicingAttributeRule.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using System.Collections.Generic;
5 | using System.Linq;
6 | using System.Reflection;
7 | using Mono.Cecil;
8 | using Mono.Collections.Generic;
9 |
10 | namespace NuGetPackageVerifier.Rules
11 | {
12 | public class AssemblyHasServicingAttributeRule : IPackageVerifierRule
13 | {
14 | public IEnumerable Validate(PackageAnalysisContext context)
15 | {
16 | AssemblyAttributesDataHelper.SetAssemblyAttributesData(context);
17 | foreach (var assemblyData in context.AssemblyData)
18 | {
19 | if (!HasServicingAttribute(assemblyData.Value.AssemblyAttributes))
20 | {
21 | yield return PackageIssueFactory.AssemblyMissingServicingAttribute(assemblyData.Key);
22 | }
23 | }
24 | }
25 |
26 | private static bool HasServicingAttribute(Collection asmAttrs)
27 | {
28 | return asmAttrs.Any(asmAttr => IsValidServicingAttribute(asmAttr));
29 | }
30 |
31 | private static bool IsValidServicingAttribute(CustomAttribute asmAttr)
32 | {
33 | if (asmAttr.AttributeType.FullName != typeof(AssemblyMetadataAttribute).FullName)
34 | {
35 | return false;
36 | }
37 | if (asmAttr.ConstructorArguments.Count != 2)
38 | {
39 | return false;
40 | }
41 |
42 | var keyValue = asmAttr.ConstructorArguments[0].Value as string;
43 | var valueValue = asmAttr.ConstructorArguments[1].Value as string;
44 |
45 | return (keyValue == "Serviceable") && (valueValue == "True");
46 | }
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/modules/NuGetPackageVerifier/console/Rules/BuildItemsRule.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using System;
5 | using System.Collections.Generic;
6 | using System.IO;
7 | using System.Linq;
8 | using NuGet.Frameworks;
9 |
10 | namespace NuGetPackageVerifier.Rules
11 | {
12 | public class BuildItemsRule : IPackageVerifierRule
13 | {
14 | public IEnumerable Validate(PackageAnalysisContext context)
15 | {
16 | var dependencyFrameworks = new HashSet(
17 | context.Metadata.DependencyGroups.Select(g => g.TargetFramework));
18 |
19 | var buildItems = context
20 | .PackageReader
21 | .GetBuildItems()
22 | .Where(f => f.Items.Any(i => IsCandidateMSBuildItem(i, context.Metadata.Id)));
23 |
24 | foreach (var buildItem in buildItems)
25 | {
26 | if (!dependencyFrameworks.Contains(buildItem.TargetFramework))
27 | {
28 | yield return PackageIssueFactory
29 | .BuildItemsDoNotMatchFrameworks(context.Metadata.Id, buildItem.TargetFramework);
30 | }
31 | }
32 | }
33 |
34 | private bool IsCandidateMSBuildItem(string file, string packageId)
35 | {
36 | if (!packageId.Equals(Path.GetFileNameWithoutExtension(file),
37 | StringComparison.OrdinalIgnoreCase))
38 | {
39 | return false;
40 | }
41 |
42 | var ext = Path.GetExtension(file);
43 | return ".props".Equals(ext, StringComparison.OrdinalIgnoreCase)
44 | || ".targets".Equals(ext, StringComparison.OrdinalIgnoreCase);
45 | }
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/modules/NuGetPackageVerifier/console/Rules/DependenciesVersionRangeBoundsRule.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using System.Collections.Generic;
5 |
6 | namespace NuGetPackageVerifier.Rules
7 | {
8 | public class DependenciesVersionRangeBoundsRule : IPackageVerifierRule
9 | {
10 | public IEnumerable Validate(PackageAnalysisContext context)
11 | {
12 | foreach (var dependencyGroup in context.Metadata.DependencyGroups)
13 | {
14 | foreach (var packageDependency in dependencyGroup.Packages)
15 | {
16 | if (packageDependency.VersionRange.HasUpperBound)
17 | {
18 | yield return PackageIssueFactory.DependencyVersionHasUpperBound(context.Metadata.Id, packageDependency.Id, dependencyGroup.TargetFramework);
19 | }
20 |
21 | if (!packageDependency.VersionRange.HasLowerBound)
22 | {
23 | yield return PackageIssueFactory.DependencyVersionDoesNotHaveLowerBound(context.Metadata.Id, packageDependency.Id, dependencyGroup.TargetFramework);
24 | }
25 | }
26 | }
27 | }
28 | }
29 | }
--------------------------------------------------------------------------------
/modules/NuGetPackageVerifier/console/Rules/PackageAuthorRule.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using System;
5 | using System.Collections.Generic;
6 | using System.Linq;
7 |
8 | namespace NuGetPackageVerifier.Rules
9 | {
10 | public class PackageAuthorRule : IPackageVerifierRule
11 | {
12 | private const string _expectedAuthor = "Microsoft";
13 |
14 | public IEnumerable Validate(PackageAnalysisContext context)
15 | {
16 | if (context.Metadata.Authors == null || !context.Metadata.Authors.Any())
17 | {
18 | yield return PackageIssueFactory.RequiredAuthor();
19 | }
20 |
21 | if (context.Metadata.Authors.Count() > 1)
22 | {
23 | yield return PackageIssueFactory.SingleAuthorOnly(context.Metadata.Id);
24 | }
25 |
26 | var author = context.Metadata.Authors.First();
27 | if (!string.Equals(author, _expectedAuthor, StringComparison.Ordinal))
28 | {
29 | yield return PackageIssueFactory.AuthorIsIncorrect(context.Metadata.Id, _expectedAuthor, author);
30 | }
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/modules/NuGetPackageVerifier/console/Rules/PackageCopyrightRule.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using System;
5 | using System.Collections.Generic;
6 | using System.Linq;
7 |
8 | namespace NuGetPackageVerifier.Rules
9 | {
10 | public class PackageCopyrightRule : IPackageVerifierRule
11 | {
12 | private const string ExpectedCopyright = "© Microsoft Corporation. All rights reserved.";
13 |
14 | public IEnumerable Validate(PackageAnalysisContext context)
15 | {
16 | if (!string.Equals(context.Metadata.Copyright, ExpectedCopyright, StringComparison.Ordinal))
17 | {
18 | yield return PackageIssueFactory.CopyrightIsIncorrect(context.Metadata.Id, ExpectedCopyright, context.Metadata.Copyright);
19 | }
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/modules/NuGetPackageVerifier/console/Rules/PackageTypesRule.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using System.Collections.Generic;
5 | using System.Linq;
6 |
7 | namespace NuGetPackageVerifier.Rules
8 | {
9 | public class PackageTypesRule : IPackageVerifierRule
10 | {
11 | public IEnumerable Validate(PackageAnalysisContext context)
12 | {
13 | var discoveredTypes = context.Metadata.PackageTypes.Select(t => t.Name);
14 | var expectedTypes = context.Options?.PackageTypes ?? Enumerable.Empty();
15 |
16 | foreach (var missing in expectedTypes.Except(discoveredTypes))
17 | {
18 | yield return PackageIssueFactory.PackageTypeMissing(missing);
19 | }
20 |
21 | foreach (var unexpected in discoveredTypes.Except(expectedTypes))
22 | {
23 | yield return PackageIssueFactory.PackageTypeUnexpected(unexpected);
24 | }
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/modules/NuGetPackageVerifier/console/Rules/PrereleaseDependenciesVersionRule.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using System.Collections.Generic;
5 |
6 | namespace NuGetPackageVerifier.Rules
7 | {
8 | public class PrereleaseDependenciesVersionRule : IPackageVerifierRule
9 | {
10 | public IEnumerable Validate(PackageAnalysisContext context)
11 | {
12 | if (context.Metadata.Version.IsPrerelease)
13 | {
14 | yield break;
15 | }
16 |
17 | foreach (var dependencyGroup in context.Metadata.DependencyGroups)
18 | {
19 | foreach (var packageDependency in dependencyGroup.Packages)
20 | {
21 | var minVersion = packageDependency.VersionRange.MinVersion;
22 | if (minVersion != null && minVersion.IsPrerelease)
23 | {
24 | yield return PackageIssueFactory.DependencyVersionIsPrereleaseForRTMPackage(
25 | context.Metadata.Id,
26 | context.Metadata.Version,
27 | packageDependency.Id,
28 | packageDependency.VersionRange.MinVersion,
29 | dependencyGroup.TargetFramework);
30 | }
31 | }
32 | }
33 | }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/modules/NuGetPackageVerifier/console/Rules/RequiredNuSpecInfoRule.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using System.Collections.Generic;
5 |
6 | namespace NuGetPackageVerifier.Rules
7 | {
8 | public class RequiredNuSpecInfoRule : IPackageVerifierRule
9 | {
10 | public IEnumerable Validate(PackageAnalysisContext context)
11 | {
12 | if (string.IsNullOrEmpty(context.Metadata.Copyright))
13 | {
14 | yield return PackageIssueFactory.RequiredCopyright();
15 | }
16 | if (context.Metadata.LicenseUrl == null)
17 | {
18 | yield return PackageIssueFactory.RequiredLicenseUrl();
19 | }
20 | if (context.Metadata.IconUrl == null)
21 | {
22 | yield return PackageIssueFactory.RequiredIconUrl();
23 | }
24 | if (context.Metadata.ProjectUrl == null)
25 | {
26 | yield return PackageIssueFactory.RequiredProjectUrl();
27 | }
28 | if (!context.Metadata.RequireLicenseAcceptance)
29 | {
30 | yield return PackageIssueFactory.RequiredRequireLicenseAcceptanceTrue();
31 | }
32 | }
33 | }
34 | }
--------------------------------------------------------------------------------
/modules/NuGetPackageVerifier/console/Rules/RequiredPackageMetadataRule.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using System.Collections.Generic;
5 |
6 | namespace NuGetPackageVerifier.Rules
7 | {
8 | public class RequiredPackageMetadataRule : IPackageVerifierRule
9 | {
10 | public IEnumerable Validate(PackageAnalysisContext context)
11 | {
12 | if (string.IsNullOrEmpty(context.Metadata.Description))
13 | {
14 | yield return PackageIssueFactory.RequiredDescription();
15 | }
16 | if (string.IsNullOrEmpty(context.Metadata.Tags))
17 | {
18 | yield return PackageIssueFactory.RequiredTags();
19 | }
20 | if (string.IsNullOrEmpty(context.Metadata.Id))
21 | {
22 | yield return PackageIssueFactory.RequiredId();
23 | }
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/modules/NuGetPackageVerifier/console/Rules/SatellitePackageRule.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using System.Collections.Generic;
5 | using NuGet.Packaging;
6 |
7 | namespace NuGetPackageVerifier.Rules
8 | {
9 | public class SatellitePackageRule : IPackageVerifierRule
10 | {
11 | public IEnumerable Validate(PackageAnalysisContext context)
12 | {
13 | if (context.PackageReader.IsSatellitePackage())
14 | {
15 | if (context.Metadata.Summary.Contains("{"))
16 | {
17 | yield return PackageIssueFactory.Satellite_PackageSummaryNotLocalized();
18 | }
19 | if (context.Metadata.Title.Contains("{"))
20 | {
21 | yield return PackageIssueFactory.Satellite_PackageTitleNotLocalized();
22 | }
23 | if (context.Metadata.Description.Contains("{"))
24 | {
25 | yield return PackageIssueFactory.Satellite_PackageDescriptionNotLocalized();
26 | }
27 | }
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/modules/NuGetPackageVerifier/console/Rules/StrictSemanticVersionValidationRule.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using System.Collections.Generic;
5 | using NuGet.Versioning;
6 |
7 | namespace NuGetPackageVerifier.Rules
8 | {
9 | public class StrictSemanticVersionValidationRule : IPackageVerifierRule
10 | {
11 | public IEnumerable Validate(PackageAnalysisContext context)
12 | {
13 | if (!SemanticVersion.TryParse(context.Metadata.Version.ToString(), out var _))
14 | {
15 | yield return PackageIssueFactory.NotSemanticVersion(context.Metadata.Version);
16 | }
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/modules/NuGetPackageVerifier/console/runtimeconfig.template.json:
--------------------------------------------------------------------------------
1 | {
2 | // Major rollforward
3 | "rollForwardOnNoCandidateFx": 2
4 | }
5 |
--------------------------------------------------------------------------------
/modules/NuGetPackageVerifier/module.targets:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 |
6 |
7 | $(VerifyDependsOn);VerifyPackages
8 |
9 |
10 |
19 |
20 | $(RepositoryRoot)NuGetPackageVerifier.json
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 | <_ExistentPackageVerifierDirectory Include="@(PackageVerifierDirectory)" Condition=" Exists('%(Identity)') " />
31 |
32 |
33 |
34 |
35 |
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/modules/NuGetPackageVerifier/msbuild/NuGetPackageVerifier.Task.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netstandard2.0
5 | NuGetPackageVerifier.Task
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/push.cmd:
--------------------------------------------------------------------------------
1 | @ECHO OFF
2 | PowerShell -NoProfile -NoLogo -ExecutionPolicy unrestricted -Command "[System.Threading.Thread]::CurrentThread.CurrentCulture = ''; [System.Threading.Thread]::CurrentThread.CurrentUICulture = '';& '%~dp0push.ps1' %*; exit $LASTEXITCODE"
3 |
--------------------------------------------------------------------------------
/scripts/UpdateDependencyVersions.ps1:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env pwsh
2 | #requires -version 4
3 |
4 | <#
5 | .SYNOPSIS
6 | The goal of the script is to make it easier for CI to automatically update and make changes to this repository, without needing
7 | to know the internal details of how config files are layed out in this repo.
8 | #>
9 | [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding = $false)]
10 | param(
11 | [Parameter()]
12 | [Alias("sdk")]
13 | [string]$DotNetSdkVersion = $null,
14 | [string]$DotNetRuntimeVersion = $null,
15 | [string[]]$GitCommitArgs = @(),
16 | [switch]$Force
17 | )
18 |
19 | $ErrorActionPreference = 'Stop'
20 | Set-StrictMode -Version 2
21 |
22 | $git = Get-Command git -ErrorAction Ignore
23 |
24 | if (!$git) {
25 | Write-Warning 'Missing recommmended command: git'
26 | }
27 |
28 | $updates = @()
29 |
30 | if ($DotNetSdkVersion -and $PSCmdlet.ShouldProcess("Update dotnet SDK to $DotNetSdkVersion")) {
31 | $path = "$PSScriptRoot/../files/KoreBuild/config/sdk.version"
32 | $currentVersion = (Get-Content -path $path -Encoding Ascii).Trim()
33 | if ($currentVersion -ne $DotNetSdkVersion) {
34 | $DotNetSdkVersion | Set-Content -path $path -Encoding Ascii
35 | if ($git) { & git add $path }
36 | $updates += "SDK to $DotNetSdkVersion"
37 | }
38 | }
39 |
40 | $message = "Updating $($updates -join ' and ')"
41 | if ($updates -and $git -and ($Force -or $PSCmdlet.ShouldContinue("Commit: $message", "Create a new commit with these changes?"))) {
42 | & $git commit -m $message @GitCommitArgs
43 | }
44 | elseif (!$updates) {
45 | Write-Warning "No changes made"
46 | }
47 |
--------------------------------------------------------------------------------
/scripts/bootstrapper/build.cmd:
--------------------------------------------------------------------------------
1 | @ECHO OFF
2 | PowerShell -NoProfile -NoLogo -ExecutionPolicy unrestricted -Command "[System.Threading.Thread]::CurrentThread.CurrentCulture = ''; [System.Threading.Thread]::CurrentThread.CurrentUICulture = '';& '%~dp0run.ps1' default-build %*; exit $LASTEXITCODE"
3 |
--------------------------------------------------------------------------------
/scripts/bootstrapper/build.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | set -euo pipefail
4 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
5 |
6 | # Call "sync" between "chmod" and execution to prevent "text file busy" error in Docker (aufs)
7 | chmod +x "$DIR/run.sh"; sync
8 | "$DIR/run.sh" default-build "$@"
9 |
--------------------------------------------------------------------------------
/scripts/bootstrapper/run.cmd:
--------------------------------------------------------------------------------
1 | @ECHO OFF
2 | PowerShell -NoProfile -NoLogo -ExecutionPolicy unrestricted -Command "[System.Threading.Thread]::CurrentThread.CurrentCulture = ''; [System.Threading.Thread]::CurrentThread.CurrentUICulture = '';& '%~dp0run.ps1' %*; exit $LASTEXITCODE"
3 |
--------------------------------------------------------------------------------
/shared/Microsoft.Extensions.CommandLineUtils.Sources/CommandLine/CommandArgument.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using System.Collections.Generic;
5 | using System.Linq;
6 |
7 | namespace Microsoft.Extensions.CommandLineUtils
8 | {
9 | internal class CommandArgument
10 | {
11 | public CommandArgument()
12 | {
13 | Values = new List();
14 | }
15 |
16 | public string Name { get; set; }
17 | public bool ShowInHelpText { get; set; } = true;
18 | public string Description { get; set; }
19 | public List Values { get; private set; }
20 | public bool MultipleValues { get; set; }
21 | public string Value
22 | {
23 | get
24 | {
25 | return Values.FirstOrDefault();
26 | }
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/shared/Microsoft.Extensions.CommandLineUtils.Sources/CommandLine/CommandOptionType.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 |
5 | namespace Microsoft.Extensions.CommandLineUtils
6 | {
7 | internal enum CommandOptionType
8 | {
9 | MultipleValue,
10 | SingleValue,
11 | NoValue
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/shared/Microsoft.Extensions.CommandLineUtils.Sources/CommandLine/CommandParsingException.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using System;
5 |
6 | namespace Microsoft.Extensions.CommandLineUtils
7 | {
8 | internal class CommandParsingException : Exception
9 | {
10 | public CommandParsingException(CommandLineApplication command, string message)
11 | : base(message)
12 | {
13 | Command = command;
14 | }
15 |
16 | public CommandLineApplication Command { get; }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/shared/Utilities/MSBuildListSplitter.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using System;
5 | using System.Collections.Generic;
6 |
7 | namespace Microsoft.AspNetCore.BuildTools
8 | {
9 | internal static class MSBuildListSplitter
10 | {
11 | public static IDictionary GetNamedProperties(string input)
12 | {
13 | if (string.IsNullOrEmpty(input))
14 | {
15 | return new Dictionary(StringComparer.OrdinalIgnoreCase);
16 | }
17 |
18 | return GetNamedProperties(input.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries));
19 | }
20 |
21 | public static IDictionary GetNamedProperties(string[] input)
22 | {
23 | var values = new Dictionary(StringComparer.OrdinalIgnoreCase);
24 | if (input == null)
25 | {
26 | return values;
27 | }
28 |
29 | foreach (var item in input)
30 | {
31 | var splitIdx = item.IndexOf('=');
32 | if (splitIdx < 0)
33 | {
34 | continue;
35 | }
36 |
37 | var key = item.Substring(0, splitIdx).Trim();
38 | if (string.IsNullOrEmpty(key))
39 | {
40 | continue;
41 | }
42 |
43 | var value = item.Substring(splitIdx + 1);
44 | values[key] = value;
45 | }
46 |
47 | return values;
48 | }
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/src/ApiCheck.Console/ApiListing/ApiElement.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using System.Diagnostics;
5 |
6 | namespace ApiCheck.Description
7 | {
8 | [DebuggerDisplay("{" + nameof(Id) + ",nq}")]
9 | public class ApiElement
10 | {
11 | public virtual string Id { get; }
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/src/ApiCheck.Console/ApiListing/ApiElementVisibility.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using Newtonsoft.Json;
5 | using Newtonsoft.Json.Converters;
6 |
7 | namespace ApiCheck.Description
8 | {
9 | [JsonConverter(typeof(StringEnumConverter))]
10 | public enum ApiElementVisibility
11 | {
12 | Public,
13 | Protected
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/src/ApiCheck.Console/ApiListing/ApiListing.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using System;
5 | using System.Collections.Generic;
6 | using System.Linq;
7 | using System.Reflection;
8 | using Newtonsoft.Json;
9 |
10 | namespace ApiCheck.Description
11 | {
12 | public class ApiListing
13 | {
14 | public string AssemblyIdentity { get; set; }
15 |
16 | public IList Types { get; } = new List();
17 |
18 | [JsonIgnore]
19 | public IEnumerable> SourceFilters { get; set; }
20 |
21 | public TypeDescriptor FindType(string name)
22 | {
23 | foreach (var type in Types)
24 | {
25 | if (string.Equals(name, type.Name, StringComparison.Ordinal))
26 | {
27 | return type;
28 | }
29 | }
30 |
31 | return null;
32 | }
33 |
34 | public ApiElement FindElement(string typeId, string memberId)
35 | {
36 | var type = Types.FirstOrDefault(t => t.Id == typeId);
37 | if (type == null)
38 | {
39 | return null;
40 | }
41 |
42 | if (memberId == null)
43 | {
44 | return type;
45 | }
46 |
47 | return type.FindMember(memberId);
48 | }
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/src/ApiCheck.Console/ApiListing/ApiListingFilters.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using System.Linq;
5 | using System.Reflection;
6 | using ApiCheck.Description;
7 |
8 | namespace ApiCheck
9 | {
10 | public static class ApiListingFilters
11 | {
12 | public static bool IsInInternalNamespace(MemberInfo e)
13 | {
14 | var type = e as TypeInfo;
15 | if (type == null)
16 | {
17 | return false;
18 | }
19 |
20 | var segments = type.Namespace.Split('.');
21 | return segments.Any(s => s == "Internal");
22 | }
23 |
24 | public static bool IsInInternalNamespace(ApiElement e)
25 | {
26 | var type = e as TypeDescriptor;
27 | if (type == null)
28 | {
29 | return false;
30 | }
31 |
32 | var segments = type.Name.Split('.');
33 | // Skip the last segment as is the type name.
34 | return segments.Take(segments.Length - 1).Any(s => s.Equals("Internal"));
35 | }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/src/ApiCheck.Console/ApiListing/MemberKind.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using Newtonsoft.Json;
5 | using Newtonsoft.Json.Converters;
6 |
7 | namespace ApiCheck.Description
8 | {
9 | [JsonConverter(typeof(StringEnumConverter))]
10 | public enum MemberKind
11 | {
12 | Constructor,
13 | // This includes property and events accessors.
14 | Method,
15 | Field
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/ApiCheck.Console/ApiListing/ParameterDirection.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using Newtonsoft.Json;
5 | using Newtonsoft.Json.Converters;
6 |
7 | namespace ApiCheck.Description
8 | {
9 | [JsonConverter(typeof(StringEnumConverter))]
10 | public enum ParameterDirection
11 | {
12 | In,
13 | Out,
14 | Ref
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/ApiCheck.Console/ApiListing/TypeKind.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using Newtonsoft.Json;
5 | using Newtonsoft.Json.Converters;
6 |
7 | namespace ApiCheck.Description
8 | {
9 | [JsonConverter(typeof(StringEnumConverter))]
10 | public enum TypeKind
11 | {
12 | Unknown,
13 | Struct,
14 | Interface,
15 | // Includes delegates as they are extend multicast delegate.
16 | Class,
17 | Enumeration
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/ApiCheck.Console/BreakingChange.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using Microsoft.DotNet.PlatformAbstractions;
5 |
6 | namespace ApiCheck
7 | {
8 | public class BreakingChange
9 | {
10 | public BreakingChange(string typeId, string memberId, ChangeKind kind)
11 | {
12 | TypeId = typeId;
13 | MemberId = memberId;
14 | Kind = kind;
15 | }
16 |
17 | public string TypeId { get; }
18 | public string MemberId { get; }
19 | public ChangeKind Kind { get; }
20 |
21 | public override bool Equals(object obj)
22 | {
23 | if (ReferenceEquals(null, obj))
24 | {
25 | return false;
26 | }
27 |
28 | if (ReferenceEquals(this, obj))
29 | {
30 | return true;
31 | }
32 |
33 | return obj.GetType() == GetType() && Equals((BreakingChange)obj);
34 | }
35 |
36 | private bool Equals(BreakingChange other)
37 | {
38 | return string.Equals(TypeId, other.TypeId) && string.Equals(MemberId, other.MemberId) && Kind == other.Kind;
39 | }
40 |
41 | public override int GetHashCode()
42 | {
43 | var hashCodeCombiner = HashCodeCombiner.Start();
44 | hashCodeCombiner.Add(TypeId);
45 | hashCodeCombiner.Add(MemberId);
46 | hashCodeCombiner.Add(Kind);
47 |
48 | return hashCodeCombiner.CombinedHash;
49 | }
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/src/ApiCheck.Console/ChangeKind.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using Newtonsoft.Json;
5 | using Newtonsoft.Json.Converters;
6 |
7 | namespace ApiCheck
8 | {
9 | [JsonConverter(typeof(StringEnumConverter))]
10 | public enum ChangeKind
11 | {
12 | Removal,
13 | Addition,
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/src/ApiCheck.Console/Loader/AssemblyLoader.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | #if NET46
5 | using System.IO;
6 | #endif
7 | using System.Reflection;
8 | #if NETCOREAPP2_1
9 | using NuGet.ProjectModel;
10 | using ApiCheck.NuGet;
11 | #endif
12 |
13 | namespace ApiCheck
14 | {
15 | public abstract class AssemblyLoader
16 | {
17 | public static Assembly LoadAssembly(
18 | string assemblyPath,
19 | string assetsJson,
20 | string framework)
21 | {
22 | #if NETCOREAPP2_1
23 | var lockFile = new LockFileFormat().Read(assetsJson);
24 | var graph = PackageGraph.Create(lockFile, framework);
25 | var loader = new CoreClrAssemblyLoader(graph, assemblyPath);
26 | #else
27 | var assemblyDirectory = Path.GetDirectoryName(assemblyPath);
28 | var loader = new FullFrameworkAssemblyLoader(assemblyDirectory);
29 | #endif
30 |
31 | return loader.Load(assemblyPath);
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/ApiCheck.Console/Loader/AssemblyNameComparer.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using System;
5 | using System.Collections.Generic;
6 | using System.Reflection;
7 |
8 | namespace ApiCheck
9 | {
10 | internal class AssemblyNameComparer : IEqualityComparer
11 | {
12 | public static readonly IEqualityComparer OrdinalIgnoreCase = new AssemblyNameComparer();
13 |
14 | public bool Equals(AssemblyName x, AssemblyName y)
15 | {
16 | // Ignore case because that's what Assembly.Load does.
17 | return string.Equals(x.Name, y.Name, StringComparison.OrdinalIgnoreCase) &&
18 | string.Equals(x.CultureName ?? string.Empty, y.CultureName ?? string.Empty, StringComparison.Ordinal);
19 | }
20 |
21 | public int GetHashCode(AssemblyName obj)
22 | {
23 | var hashCode = 0;
24 | if (obj.Name != null)
25 | {
26 | hashCode ^= obj.Name.GetHashCode();
27 | }
28 |
29 | hashCode ^= (obj.CultureName ?? string.Empty).GetHashCode();
30 | return hashCode;
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/src/ApiCheck.Console/Loader/FullFrameworkAssemblyLoader.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | #if !NETCOREAPP2_1
5 |
6 | using System;
7 | using System.Collections.Generic;
8 | using System.IO;
9 | using System.Linq;
10 | using System.Reflection;
11 |
12 | namespace ApiCheck
13 | {
14 | public class FullFrameworkAssemblyLoader
15 | {
16 | private readonly Dictionary _resolvedDlls;
17 |
18 | public FullFrameworkAssemblyLoader(string probingPath)
19 | {
20 | var directory = new DirectoryInfo(probingPath);
21 | _resolvedDlls = directory.EnumerateFiles("*.dll")
22 | .ToDictionary(f => GetAssemblyName(f.FullName), f => f.FullName, new AssemblyNameComparer());
23 |
24 | AppDomain.CurrentDomain.AssemblyResolve += Resolver;
25 | }
26 |
27 | private AssemblyName GetAssemblyName(string assemblyPath) => AssemblyName.GetAssemblyName(assemblyPath);
28 |
29 | private Assembly Resolver(object sender, ResolveEventArgs args)
30 | {
31 | var name = new AssemblyName(args.Name);
32 | var path = FindAssemblyPath(name);
33 |
34 | return path != null ? Assembly.LoadFile(path) : null;
35 | }
36 |
37 | private string FindAssemblyPath(AssemblyName name) => _resolvedDlls.TryGetValue(name, out var path) ? path : null;
38 |
39 | public Assembly Load(string assemblyPath) => Assembly.LoadFile(assemblyPath);
40 | }
41 | }
42 |
43 | #endif
--------------------------------------------------------------------------------
/src/ApiCheck.Console/Microsoft.AspNetCore.BuildTools.ApiCheck.nuspec:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | $id$
5 | $version$
6 | Microsoft
7 | Generates API baselines and detects breaking changes in APIs.
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/src/ApiCheck.Console/NuGet/PackageAssembly.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using System.IO;
5 |
6 | namespace ApiCheck.NuGet
7 | {
8 | public class PackageAssembly
9 | {
10 | public PackageAssembly(string relativePath, string resolvedPath)
11 | {
12 | RelativePath = relativePath;
13 | ResolvedPath = resolvedPath;
14 | }
15 |
16 | public string FileName => Path.GetFileName(ResolvedPath);
17 | public string RelativePath { get; set; }
18 | public string ResolvedPath { get; set; }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/ApiCheck.Console/NuGet/RuntimeDefinition.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using System.Collections.Generic;
5 |
6 | namespace ApiCheck.NuGet
7 | {
8 | public class RuntimeDefinition
9 | {
10 | public string Name { get; set; }
11 | public IEnumerable Fallbacks { get; set; }
12 |
13 | public override string ToString()
14 | {
15 | return Name;
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/ApiCheck.Console/README.md:
--------------------------------------------------------------------------------
1 | Api Check
2 | ===========
3 | The documentation for this project can be found [here](https://github.com/aspnet/BuildTools/wiki/Api-Check).
--------------------------------------------------------------------------------
/src/ApiCheck.Console/build/Microsoft.AspNetCore.BuildTools.ApiCheck.props:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 | <_ApiCheckTaskAssembly>$(MSBuildThisFileDirectory)..\tools\netstandard2.0\Microsoft.AspNetCore.BuildTools.ApiCheck.Task.dll
8 |
9 |
10 |
13 |
16 |
17 |
--------------------------------------------------------------------------------
/src/ApiCheck.Task/ApiCheck.Task.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netstandard2.0
5 | false
6 | Microsoft.AspNetCore.BuildTools.ApiCheck.Task
7 | Microsoft.AspNetCore.BuildTools.ApiCheck.Task
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/src/ApiCheck.Task/ApiCheckGenerateTask.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 |
5 | using System;
6 | using System.IO;
7 | using Microsoft.Build.Framework;
8 | using System.Reflection;
9 |
10 | namespace Microsoft.AspNetCore.BuildTools.ApiCheck.Task
11 | {
12 | ///
13 | /// An MSBuild task that acts as a shim to Microsoft.AspNetCore.BuildTools.ApiCheck.exe generate ... or
14 | /// dotnet Microsoft.AspNetCore.BuildTools.ApiCheck.dll generate ....
15 | ///
16 | public class ApiCheckGenerateTask : ApiCheckTasksBase
17 | {
18 | protected override bool ValidateParameters()
19 | {
20 | if (string.IsNullOrEmpty(ApiListingPath))
21 | {
22 | Log.LogError($"API listing file '{ApiListingPath}' not specified.");
23 | return false;
24 | }
25 |
26 | return base.ValidateParameters();
27 | }
28 |
29 | protected override string GenerateCommandLineCommands()
30 | {
31 | return GenerateCommandLineCommands("generate");
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/Internal.AspNetCore.Sdk/Internal.AspNetCore.Sdk.nuspec:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | $id$
5 | $version$
6 | Microsoft
7 | false
8 | $description$
9 | $copyright$
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/src/Internal.AspNetCore.Sdk/_._:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aspnet/BuildTools/d35d7d63ceecbf0d937b2f0d06f041ca61c14f2c/src/Internal.AspNetCore.Sdk/_._
--------------------------------------------------------------------------------
/src/Internal.AspNetCore.Sdk/build/ApiCheck.props:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
8 |
9 | <_ApiCheckIsSupported Condition=" '$(OS)' != 'Windows_NT' ">false
10 |
11 |
12 | <_ApiCheckIsSupported Condition=" '$(MSBuildRuntimeType)' != 'Core' ">false
13 |
14 |
15 | true
16 |
17 | true
18 |
19 |
20 | $(GenerateNuspecDependsOn);Generate-ApiCheck-Baselines
21 | $(GenerateNuspecDependsOn);Replace-ApiCheck-Baselines
22 | $(GenerateNuspecDependsOn);ApiCheck
23 |
24 |
25 |
--------------------------------------------------------------------------------
/src/Internal.AspNetCore.Sdk/build/DotNetTool.targets:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | $(MSBuildAllProjects);$(MSBuildThisFileFullPath)
5 | $(GetSignedPackageFilesDependsOn);_GetSignedPackageFilesForGeneratedShims
6 | $(OutDir)
7 |
8 |
9 |
10 |
11 | <_ShimRids Include="$(PackAsToolShimRuntimeIdentifiers)" />
12 |
13 | tools/$(TargetFramework)/any/shims/%(_ShimRids.Identity)/
14 |
15 |
16 | tools/$(TargetFramework)/any/$(TargetFileName)
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/src/Internal.AspNetCore.Sdk/build/Internal.AspNetCore.Sdk.props:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/src/Internal.AspNetCore.Sdk/build/Internal.AspNetCore.Sdk.targets:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
14 |
15 |
17 |
18 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/src/Internal.AspNetCore.Sdk/buildMultiTargeting/ApiCheck.targets:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
9 |
10 | <_TargetFrameworks Remove="@(_TargetFrameworks)" />
11 | <_TargetFrameworks Include="$(TargetFrameworks)" />
12 |
13 |
14 |
18 |
19 |
20 |
22 |
23 | <_TargetFrameworks Remove="@(_TargetFrameworks)" />
24 | <_TargetFrameworks Include="$(TargetFrameworks)" />
25 |
26 |
27 |
31 |
32 |
33 |
34 |
35 | <_TargetFrameworks Remove="@(_TargetFrameworks)" />
36 | <_TargetFrameworks Include="$(TargetFrameworks)" />
37 |
38 |
39 |
43 |
44 |
45 |
--------------------------------------------------------------------------------
/src/Internal.AspNetCore.Sdk/buildMultiTargeting/Internal.AspNetCore.Sdk.props:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
8 |
9 | false
10 |
11 |
12 | false
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/src/Internal.AspNetCore.Sdk/buildMultiTargeting/Internal.AspNetCore.Sdk.targets:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
8 |
9 |
10 |
11 | <_TargetFrameworks Remove="@(_TargetFrameworks)" />
12 | <_TargetFrameworks Include="$(TargetFrameworks)" />
13 |
14 |
17 |
18 |
19 |
20 |
21 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/src/Internal.AspNetCore.SiteExtension.Sdk/Internal.AspNetCore.SiteExtension.Sdk.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Internal.AspNetCore.SiteExtension.Sdk
5 | netcoreapp2.1;net46
6 | false
7 | Build targets and extensions to Microsoft.NET.Sdk. This package is intended for Microsoft use only.
8 | $(MSBuildThisFileDirectory)$(MSBuildProjectName).nuspec
9 | false
10 | false
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 | $(NuspecProperties);id=$(PackageId)
24 | $(NuspecProperties);config=$(Configuration)
25 | $(NuspecProperties);version=$(PackageVersion)
26 | $(NuspecProperties);description=$(Description)
27 | $(NuspecProperties);copyright=$(Copyright)
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/src/Internal.AspNetCore.SiteExtension.Sdk/Internal.AspNetCore.SiteExtension.Sdk.nuspec:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | $id$
5 | $version$
6 | Microsoft
7 | false
8 | $description$
9 | $copyright$
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/src/Internal.AspNetCore.SiteExtension.Sdk/TrimDeps.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using System.IO;
5 | using System.Linq;
6 | using Microsoft.Build.Framework;
7 | using Microsoft.Build.Utilities;
8 | using Newtonsoft.Json;
9 | using Newtonsoft.Json.Linq;
10 |
11 | namespace RepoTasks
12 | {
13 | public class TrimDeps : Task
14 | {
15 | [Required]
16 | public ITaskItem[] DepsFiles { get; set; }
17 |
18 | public override bool Execute()
19 | {
20 | foreach (var depsFile in DepsFiles)
21 | {
22 | ChangeEntryPointLibraryName(depsFile.ItemSpec);
23 | }
24 |
25 | // Parse input
26 | return true;
27 | }
28 |
29 |
30 | private void ChangeEntryPointLibraryName(string depsFile)
31 | {
32 | JToken deps;
33 | using (var file = File.OpenText(depsFile))
34 | using (JsonTextReader reader = new JsonTextReader(file))
35 | {
36 | deps = JObject.ReadFrom(reader);
37 | }
38 |
39 | foreach (JProperty target in deps["targets"])
40 | {
41 | var targetLibrary = target.Value.Children().FirstOrDefault();
42 | if (targetLibrary == null)
43 | {
44 | continue;
45 | }
46 |
47 | targetLibrary.Remove();
48 | }
49 |
50 | var library = deps["libraries"].Children().First();
51 | library.Remove();
52 |
53 | using (var file = File.CreateText(depsFile))
54 | using (var writer = new JsonTextWriter(file) { Formatting = Formatting.Indented })
55 | {
56 | deps.WriteTo(writer);
57 | }
58 | }
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/src/Internal.AspNetCore.SiteExtension.Sdk/_._:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aspnet/BuildTools/d35d7d63ceecbf0d937b2f0d06f041ca61c14f2c/src/Internal.AspNetCore.SiteExtension.Sdk/_._
--------------------------------------------------------------------------------
/src/Internal.AspNetCore.SiteExtension.Sdk/build/Internal.AspNetCore.SiteExtension.Sdk.props:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 | netcoreapp2.1
8 | net46
9 | $(MSBuildThisFileDirectory)..\tools\$(TaskFolder)\Internal.AspNetCore.SiteExtension.Sdk.dll
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/src/Internal.AspNetCore.SiteExtension.Sdk/content/HostingStartup/HostingStartup.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netcoreapp2.1
5 | Exe
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/src/Internal.AspNetCore.SiteExtension.Sdk/content/HostingStartup/Program.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation and contributors. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | public class Program
5 | {
6 | public static void Main() { }
7 | }
--------------------------------------------------------------------------------
/test.ps1:
--------------------------------------------------------------------------------
1 | #requires -version 4
2 | [CmdletBinding(PositionalBinding = $false)]
3 | param(
4 | [Parameter()]
5 | [string]$Command = 'default-build',
6 | [Parameter(Mandatory = $true)]
7 | [string]$RepoPath,
8 | [switch]$NoBuild = $false,
9 | [switch]$CI = $false,
10 | [Parameter(ValueFromRemainingArguments = $true)]
11 | [string[]]$Arguments
12 | )
13 |
14 | $ErrorActionPreference = 'Stop'
15 |
16 | # Don't not use this to not build first
17 | if (-not $NoBuild) {
18 | & git clean .\artifacts -xdf
19 |
20 | & .\build.ps1 '-p:SkipTests=true'
21 | }
22 |
23 | [xml] $versionProps = Get-Content "$PSScriptRoot/version.props"
24 | $channel = $versionProps.Project.PropertyGroup.KoreBuildChannel
25 | $toolsSource = "$PSScriptRoot/artifacts/"
26 | $latestFile = Join-Path $toolsSource "korebuild/channels/$channel/latest.txt"
27 | $toolsVersion = $null
28 | foreach ($line in Get-Content $latestFile) {
29 | $toolsVersion = $line.Split(":")[1]
30 | break
31 | }
32 |
33 | $packageDir = Join-Path $toolsSource "build\"
34 |
35 | $Arguments += , "/p:InternalAspNetCoreSdkPackageVersion=$toolsVersion"
36 | $Arguments += , "/p:DotNetRestoreSources=$packageDir"
37 |
38 | foreach ($pkg in @(
39 | "Internal.AspNetCore.Sdk",
40 | "Internal.AspNetCore.SiteExtension.Sdk",
41 | "Microsoft.AspNetCore.BuildTools.ApiCheck")) {
42 |
43 | $pkgRoot = "${env:USERPROFILE}/.nuget/packages/$pkg/$toolsVersion/"
44 | if (Test-Path $pkgRoot) {
45 | Remove-Item -Recurse -Force $pkgRoot
46 | }
47 | }
48 |
49 |
50 | & .\scripts\bootstrapper\run.ps1 -Update -Reinstall -Command $Command -Path $RepoPath -ToolsSource $toolsSource -Ci:$CI @Arguments
51 |
--------------------------------------------------------------------------------
/test.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | set -euo pipefail
4 |
5 | command='default-build'
6 | repo_path=''
7 | no_build=false
8 | msbuild_args=()
9 |
10 | while [[ $# -gt 0 ]]; do
11 | case $1 in
12 | --no-build|-NoBuild)
13 | no_build=true
14 | ;;
15 | -r|--repo-path|-RepoPath)
16 | shift
17 | repo_path="$1"
18 | ;;
19 | -c|--command|-Command)
20 | shift
21 | command="$1"
22 | ;;
23 | *)
24 | msbuild_args[${#msbuild_args[*]}]="$1"
25 | ;;
26 | esac
27 | shift
28 | done
29 |
30 | if [ -z "$repo_path" ]; then
31 | echo "Missing required value for --repo-path"
32 | exit 1
33 | fi
34 |
35 | if [ "$no_build" = false ]; then
36 | ./build.sh /p:SkipTests=true
37 | fi
38 |
39 | ./scripts/bootstrapper/run.sh \
40 | "$command" \
41 | -Path "$repo_path" \
42 | -ToolsSource ./artifacts/ \
43 | -Update \
44 | -Reinstall \
45 | ${msbuild_args[@]+"${msbuild_args[@]}"}
46 |
--------------------------------------------------------------------------------
/test/ApiCheck.Test/ApiCheck.Test.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netcoreapp2.1;net461
5 | netcoreapp2.1
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/test/ApiCheckBaseline.V1/ApiCheckBaseline.V1.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netstandard1.6;net452;netcoreapp2.1
5 | false
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/test/ApiCheckBaseline.V2/ApiCheckBaseline.V2.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netstandard1.6;net452;netcoreapp2.1
5 | false
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/test/ApiCheckBaseline.V2/Scenarios.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | namespace ApiCheckApiListing.V2
5 | {
6 | public class ApiCheckApiListingV2
7 | {
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/test/ApiCheckForwardDestination/ApiCheckForwardDestination.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netstandard1.6;net452;netcoreapp2.1
5 | false
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/test/ApiCheckForwardDestination/ComparisonScenarios.cs:
--------------------------------------------------------------------------------
1 | namespace ComparisonScenarios
2 | {
3 | public class TypeToBeForwarded
4 | {
5 | public string Name { get; set; }
6 | }
7 |
8 | public class TypeToBeForwardedAndChanged
9 | {
10 | public string Name { get; set; }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/test/BuildTools.Tasks.Tests/BuildTools.Tasks.Tests.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netcoreapp2.1
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/test/BuildTools.Tasks.Tests/GenerateResxDesignerFilesTest.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using System;
5 | using System.IO;
6 | using Microsoft.AspNetCore.BuildTools;
7 | using Microsoft.Build.Utilities;
8 | using Xunit;
9 |
10 | namespace BuildTools.Tasks.Tests
11 | {
12 | public class GenerateResxDesignerFilesTest
13 | {
14 | [Fact]
15 | public void GeneratesResx()
16 | {
17 | var resx = Path.Combine(AppContext.BaseDirectory, "Resources", "Strings.resx");
18 |
19 | var item = new TaskItem(resx);
20 | item.SetMetadata("ManifestResourceName", "Microsoft.Extensions.Logging.Abstractions.Resource");
21 | item.SetMetadata("Type", "Resx");
22 |
23 | var engine = new MockEngine();
24 | var task = new GenerateResxDesignerFiles
25 | {
26 | ResourceFiles = new[] { item },
27 | BuildEngine = engine,
28 | };
29 |
30 | var expectedFile = Path.Combine(AppContext.BaseDirectory, "Resources", "Strings.Designer.cs.txt");
31 | var actualFile = Path.Combine(AppContext.BaseDirectory, "Resources", "Strings.Designer.cs");
32 | if (File.Exists(actualFile))
33 | {
34 | File.Delete(actualFile);
35 | }
36 |
37 | Assert.True(task.Execute(), "Task failed");
38 | Assert.Empty(engine.Warnings);
39 |
40 | Assert.Equal(actualFile, Assert.Single(task.FileWrites).ItemSpec);
41 | Assert.True(File.Exists(actualFile), "Actual file does not exist");
42 | Assert.Equal(File.ReadAllText(expectedFile), File.ReadAllText(actualFile), ignoreLineEndingDifferences: true);
43 | }
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/test/BuildTools.Tasks.Tests/GetAssemblyFileVersionTest.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using Xunit;
5 |
6 | namespace Microsoft.AspNetCore.BuildTools
7 | {
8 | public class GetAssemblyFileVersionTest
9 | {
10 | [Fact]
11 | public void Execute_SetsAssemblyFileVersionToAssemblyVersion_IfRevisionIsSet()
12 | {
13 | // Arrange
14 | var getAssemblyFileVersion = new GetAssemblyFileVersion
15 | {
16 | AssemblyVersion = "1.2.3.4",
17 | AssemblyRevision = 78,
18 | };
19 |
20 | // Act
21 | var result = getAssemblyFileVersion.Execute();
22 |
23 | // Assert
24 | Assert.True(result);
25 | Assert.Equal("1.2.3.4", getAssemblyFileVersion.AssemblyFileVersion);
26 | }
27 |
28 | [Theory]
29 | [InlineData("1.2.3")]
30 | [InlineData("1.2.3.0")]
31 | public void Execute_UsesAssemblyRevision_IfRevisionIsNotSet(string assemblyVersion)
32 | {
33 | // Arrange
34 | var getAssemblyFileVersion = new GetAssemblyFileVersion
35 | {
36 | AssemblyVersion = assemblyVersion,
37 | AssemblyRevision = 78,
38 | };
39 |
40 | // Act
41 | var result = getAssemblyFileVersion.Execute();
42 |
43 | // Assert
44 | Assert.True(result);
45 | Assert.Equal("1.2.3.78", getAssemblyFileVersion.AssemblyFileVersion);
46 | }
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/test/BuildTools.Tasks.Tests/Resources/SimpleGitRepo.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aspnet/BuildTools/d35d7d63ceecbf0d937b2f0d06f041ca61c14f2c/test/BuildTools.Tasks.Tests/Resources/SimpleGitRepo.zip
--------------------------------------------------------------------------------
/test/BuildTools.Tasks.Tests/Resources/SparseCheckout.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aspnet/BuildTools/d35d7d63ceecbf0d937b2f0d06f041ca61c14f2c/test/BuildTools.Tasks.Tests/Resources/SparseCheckout.zip
--------------------------------------------------------------------------------
/test/BuildTools.Tasks.Tests/Resources/Strings.Designer.cs.txt:
--------------------------------------------------------------------------------
1 | //
2 | namespace Microsoft.Extensions.Logging.Abstractions
3 | {
4 | using System.Globalization;
5 | using System.Reflection;
6 | using System.Resources;
7 |
8 | internal static class Resource
9 | {
10 | private static readonly ResourceManager _resourceManager
11 | = new ResourceManager("Microsoft.Extensions.Logging.Abstractions.Resource", typeof(Resource).GetTypeInfo().Assembly);
12 |
13 | ///
14 | /// The format string '{0}' does not have the expected number of named parameters. Expected {1} parameter(s) but found {2} parameter(s).
15 | ///
16 | internal static string UnexpectedNumberOfNamedParameters
17 | {
18 | get => GetString("UnexpectedNumberOfNamedParameters");
19 | }
20 |
21 | ///
22 | /// The format string '{0}' does not have the expected number of named parameters. Expected {1} parameter(s) but found {2} parameter(s).
23 | ///
24 | internal static string FormatUnexpectedNumberOfNamedParameters(object p0, object p1, object p2)
25 | => string.Format(CultureInfo.CurrentCulture, GetString("UnexpectedNumberOfNamedParameters"), p0, p1, p2);
26 |
27 | private static string GetString(string name, params string[] formatterNames)
28 | {
29 | var value = _resourceManager.GetString(name);
30 |
31 | System.Diagnostics.Debug.Assert(value != null);
32 |
33 | if (formatterNames != null)
34 | {
35 | for (var i = 0; i < formatterNames.Length; i++)
36 | {
37 | value = value.Replace("{" + formatterNames[i] + "}", "{" + i + "}");
38 | }
39 | }
40 |
41 | return value;
42 | }
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/test/BuildTools.Tasks.Tests/Resources/SubmoduleRepo.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aspnet/BuildTools/d35d7d63ceecbf0d937b2f0d06f041ca61c14f2c/test/BuildTools.Tasks.Tests/Resources/SubmoduleRepo.zip
--------------------------------------------------------------------------------
/test/BuildTools.Tasks.Tests/Resources/WorktreeRepo.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aspnet/BuildTools/d35d7d63ceecbf0d937b2f0d06f041ca61c14f2c/test/BuildTools.Tasks.Tests/Resources/WorktreeRepo.zip
--------------------------------------------------------------------------------
/test/BuildTools.Tasks.Tests/Resources/sampledata.json:
--------------------------------------------------------------------------------
1 | {
2 | "sdk": { "version": "1.2.3" },
3 | "runtimes": [
4 | {
5 | "version": "1.0.0-beta"
6 | },
7 | {
8 | "version": "1.0.0-alpha"
9 | }
10 | ]
11 | }
12 |
--------------------------------------------------------------------------------
/test/BuildTools.Tasks.Tests/RunTaskTests.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using System;
5 | using System.IO;
6 | using Microsoft.AspNetCore.BuildTools;
7 | using Xunit;
8 |
9 | namespace BuildTools.Tasks.Tests
10 | {
11 | public class RunTaskTests
12 | {
13 | [Fact]
14 | public void ExitCodeIsNonZeroIfFailedToStart()
15 | {
16 | var engine = new MockEngine { ContinueOnError = true };
17 | var task = new Run
18 | {
19 | FileName = "sdfkjskldfsjdflkajsdas",
20 | BuildEngine = engine,
21 | };
22 | Assert.False(task.Execute());
23 | Assert.NotEqual(0, task.ExitCode);
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/test/Directory.Build.targets:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/test/KoreBuild.FunctionalTests/GenerateTestProps.targets:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
7 |
8 | $([MSBuild]::Escape($(RestoreSources)))
9 |
10 |
11 | ]]>
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/test/KoreBuild.FunctionalTests/KoreBuild.FunctionalTests.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netcoreapp2.1
5 |
6 |
7 |
8 |
9 | <_Parameter1>NuGetPackageRoot
10 | <_Parameter2>$(NuGetPackageRoot)
11 |
12 |
13 | <_Parameter1>PackageVersion
14 | <_Parameter2>$(PackageVersion)
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/test/KoreBuild.Tasks.Tests/KoreBuild.Tasks.Tests.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netcoreapp2.1
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 | PreserveNewest
33 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/test/KoreBuild.Tasks.Tests/TestResources/lorem.bin:
--------------------------------------------------------------------------------
1 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque et nulla laoreet ex pharetra congue. Sed gravida justo orci. Nunc nec est vitae purus accumsan consectetur et vel risus. Sed lobortis nulla eu feugiat ornare. Pellentesque ornare semper lorem at vestibulum. Aliquam molestie erat nunc. Curabitur suscipit aliquet quam quis fringilla.
2 |
--------------------------------------------------------------------------------
/test/xunit.runner.json:
--------------------------------------------------------------------------------
1 | {
2 | "methodDisplay": "method"
3 | }
4 |
--------------------------------------------------------------------------------
/testassets/RepoThatShouldFailToBuild/Directory.Build.props:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/testassets/RepoThatShouldFailToBuild/Directory.Build.targets:
--------------------------------------------------------------------------------
1 |
4 |
5 |
--------------------------------------------------------------------------------
/testassets/RepoThatShouldFailToBuild/build/dependencies.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/testassets/RepoThatShouldFailToBuild/korebuild.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://raw.githubusercontent.com/aspnet/BuildTools/release/2.1/tools/korebuild.schema.json",
3 | "channel": "release/2.1"
4 | }
5 |
--------------------------------------------------------------------------------
/testassets/RepoThatShouldFailToBuild/src/BadConsole/BadConsole.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | netcoreapp2.1
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/testassets/RepoThatShouldFailToBuild/src/BadConsole/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace BadConsole
4 | {
5 | class Program
6 | {
7 |
8 | This syntax error is deliberate. We want to ensure KoreBuild returns with a non-zero code.
9 |
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/testassets/RepoWithGlobalTool/Directory.Build.props:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/testassets/RepoWithGlobalTool/Directory.Build.targets:
--------------------------------------------------------------------------------
1 |
4 |
5 |
--------------------------------------------------------------------------------
/testassets/RepoWithGlobalTool/RepoWithGlobalTool.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 15
4 | VisualStudioVersion = 15.0.26124.0
5 | MinimumVisualStudioVersion = 15.0.26124.0
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GlobalConsoleTool", "src\GlobalConsoleTool\GlobalConsoleTool.csproj", "{4F0E73BA-1E8D-41B2-8FE8-59E58228224F}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Debug|x64 = Debug|x64
12 | Debug|x86 = Debug|x86
13 | Release|Any CPU = Release|Any CPU
14 | Release|x64 = Release|x64
15 | Release|x86 = Release|x86
16 | EndGlobalSection
17 | GlobalSection(SolutionProperties) = preSolution
18 | HideSolutionNode = FALSE
19 | EndGlobalSection
20 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
21 | {4F0E73BA-1E8D-41B2-8FE8-59E58228224F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
22 | {4F0E73BA-1E8D-41B2-8FE8-59E58228224F}.Debug|Any CPU.Build.0 = Debug|Any CPU
23 | {4F0E73BA-1E8D-41B2-8FE8-59E58228224F}.Debug|x64.ActiveCfg = Debug|Any CPU
24 | {4F0E73BA-1E8D-41B2-8FE8-59E58228224F}.Debug|x64.Build.0 = Debug|Any CPU
25 | {4F0E73BA-1E8D-41B2-8FE8-59E58228224F}.Debug|x86.ActiveCfg = Debug|Any CPU
26 | {4F0E73BA-1E8D-41B2-8FE8-59E58228224F}.Debug|x86.Build.0 = Debug|Any CPU
27 | {4F0E73BA-1E8D-41B2-8FE8-59E58228224F}.Release|Any CPU.ActiveCfg = Release|Any CPU
28 | {4F0E73BA-1E8D-41B2-8FE8-59E58228224F}.Release|Any CPU.Build.0 = Release|Any CPU
29 | {4F0E73BA-1E8D-41B2-8FE8-59E58228224F}.Release|x64.ActiveCfg = Release|Any CPU
30 | {4F0E73BA-1E8D-41B2-8FE8-59E58228224F}.Release|x64.Build.0 = Release|Any CPU
31 | {4F0E73BA-1E8D-41B2-8FE8-59E58228224F}.Release|x86.ActiveCfg = Release|Any CPU
32 | {4F0E73BA-1E8D-41B2-8FE8-59E58228224F}.Release|x86.Build.0 = Release|Any CPU
33 | EndGlobalSection
34 | EndGlobal
35 |
--------------------------------------------------------------------------------
/testassets/RepoWithGlobalTool/build/dependencies.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/testassets/RepoWithGlobalTool/korebuild.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://raw.githubusercontent.com/aspnet/BuildTools/release/2.1/tools/korebuild.schema.json",
3 | "channel": "release/2.1"
4 | }
5 |
--------------------------------------------------------------------------------
/testassets/RepoWithGlobalTool/src/GlobalConsoleTool/GlobalConsoleTool.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | netcoreapp2.1
6 | true
7 | win-x64;win-x86
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/testassets/RepoWithGlobalTool/src/GlobalConsoleTool/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace GlobalConsoleTool
4 | {
5 | class Program
6 | {
7 | static void Main(string[] args)
8 | {
9 | Console.WriteLine("Hello World!");
10 | }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/testassets/SimpleRepo/Directory.Build.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/testassets/SimpleRepo/Directory.Build.targets:
--------------------------------------------------------------------------------
1 |
4 |
5 |
--------------------------------------------------------------------------------
/testassets/SimpleRepo/NuGetPackageVerifier.json:
--------------------------------------------------------------------------------
1 | {
2 | "Default": {
3 | "rules": [
4 | "AssemblyHasVersionAttributesRule",
5 | "DotNetToolPackageRule"
6 | ],
7 | "packages": {
8 | "Simple.CliTool": {
9 | "Exclusions": {
10 | "VERSION_INFORMATIONALVERSION": {
11 | "tools/netcoreapp2.1/any/Newtonsoft.Json.dll": "Example exclusion"
12 | }
13 | }
14 | }
15 | }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/testassets/SimpleRepo/build/Sample.Lineup.nuspec:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Sample.Lineup
5 | $version$
6 | KoreBuild
7 | Description.
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/testassets/SimpleRepo/build/dependencies.props:
--------------------------------------------------------------------------------
1 |
2 |
3 | $(MSBuildAllProjects);$(MSBuildThisFileFullPath)
4 |
5 |
6 | 0.0.1
7 | 10.0.1
8 | 15.5.0
9 | 2.3.1
10 | 2.3.1
11 |
12 |
13 |
14 | $(KoreBuildVersion)
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/testassets/SimpleRepo/build/repo.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/testassets/SimpleRepo/build/repo.targets:
--------------------------------------------------------------------------------
1 |
2 |
3 | $(PrepareDependsOn);Greet
4 | $(PackageDependsOn);PackLineup
5 | $(VerifyDependsOn);TestNuGetPush;UpgradeDependencies
6 |
7 | Sample.Lineup
8 | $(Version)
9 | $(IntermediateDir)
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/testassets/SimpleRepo/build/sources.props:
--------------------------------------------------------------------------------
1 |
2 |
3 | $(RestoreAdditionalProjectSources);$(KoreBuildBundledPackageFolder)
4 |
5 |
6 |
--------------------------------------------------------------------------------
/testassets/SimpleRepo/build/tasks/RepoTasks.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | netcoreapp2.1
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/testassets/SimpleRepo/build/tasks/RepoTasks.tasks:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/testassets/SimpleRepo/build/tasks/SayHello.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.Build.Framework;
2 | using Microsoft.Build.Utilities;
3 |
4 | namespace RepoTasks
5 | {
6 | public class SayHello : Task
7 | {
8 | public override bool Execute()
9 | {
10 | Log.LogMessage(MessageImportance.High, "Aloha");
11 | return true;
12 | }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/testassets/SimpleRepo/korebuild.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://raw.githubusercontent.com/aspnet/BuildTools/release/2.1/tools/korebuild.schema.json",
3 | "channel": "release/2.1"
4 | }
5 |
--------------------------------------------------------------------------------
/testassets/SimpleRepo/samples/Simple.Sample/Program.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using System;
5 |
6 | namespace Simple.Sample
7 | {
8 | class Program
9 | {
10 | static void Main(string[] args)
11 | {
12 | Console.WriteLine("Hello World!");
13 | }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/testassets/SimpleRepo/samples/Simple.Sample/Simple.Sample.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Exe
9 | netcoreapp2.1
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/testassets/SimpleRepo/shared/Simple.Sources/Example.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | namespace Simple
5 | {
6 | public class Example
7 | {
8 |
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/testassets/SimpleRepo/src/Simple.CliTool/Program.cs:
--------------------------------------------------------------------------------
1 | using static System.Console;
2 |
3 | class Program
4 | {
5 | public static void Main(string[] args)
6 | => WriteLine(@"
7 | ______
8 | ( Moo! )
9 | ------
10 | \ ^__^
11 | \ (oo)\_______
12 | (__)\ )\/\
13 | ||----w |
14 | || ||");
15 | }
16 |
--------------------------------------------------------------------------------
/testassets/SimpleRepo/src/Simple.CliTool/Simple.CliTool.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netcoreapp2.1
5 | exe
6 | DotnetTool
7 | cowsay
8 | Simple.CliTool
9 | true
10 | win-x64;win-x86
11 | TestCert
12 | MyPackageSigningCert
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 | tools/$(TargetFramework)/any/Newtonsoft.Json.dll
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/testassets/SimpleRepo/src/Simple.Lib/Api.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Simple.Lib
4 | {
5 | public class Api
6 | {
7 | public string Name { get; set; } = nameof(Api);
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/testassets/SimpleRepo/src/Simple.Lib/Simple.Lib.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netstandard2.0;net461
5 | TestCert
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/testassets/SimpleRepo/src/Simple.Lib/baseline.netcore.json:
--------------------------------------------------------------------------------
1 | {
2 | "AssemblyIdentity": "Simple.Lib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null",
3 | "Types": [
4 | {
5 | "Name": "Simple.Lib.Api",
6 | "Visibility": "Public",
7 | "Kind": "Class",
8 | "ImplementedInterfaces": [],
9 | "Members": [
10 | {
11 | "Kind": "Method",
12 | "Name": "get_OldName",
13 | "Parameters": [],
14 | "ReturnType": "System.String",
15 | "Visibility": "Public",
16 | "GenericParameter": []
17 | },
18 | {
19 | "Kind": "Method",
20 | "Name": "get_Name",
21 | "Parameters": [],
22 | "ReturnType": "System.String",
23 | "Visibility": "Public",
24 | "GenericParameter": []
25 | },
26 | {
27 | "Kind": "Method",
28 | "Name": "set_Name",
29 | "Parameters": [
30 | {
31 | "Name": "value",
32 | "Type": "System.String"
33 | }
34 | ],
35 | "ReturnType": "System.Void",
36 | "Visibility": "Public",
37 | "GenericParameter": []
38 | },
39 | {
40 | "Kind": "Constructor",
41 | "Name": ".ctor",
42 | "Parameters": [],
43 | "Visibility": "Public",
44 | "GenericParameter": []
45 | }
46 | ],
47 | "GenericParameters": []
48 | }
49 | ]
50 | }
51 |
--------------------------------------------------------------------------------
/testassets/SimpleRepo/src/Simple.Lib/baseline.netframework.json:
--------------------------------------------------------------------------------
1 | {
2 | "AssemblyIdentity": "Simple.Lib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null",
3 | "Types": [
4 | {
5 | "Name": "Simple.Lib.Api",
6 | "Visibility": "Public",
7 | "Kind": "Class",
8 | "ImplementedInterfaces": [],
9 | "Members": [
10 | {
11 | "Kind": "Method",
12 | "Name": "get_OldName",
13 | "Parameters": [],
14 | "ReturnType": "System.String",
15 | "Visibility": "Public",
16 | "GenericParameter": []
17 | },
18 | {
19 | "Kind": "Method",
20 | "Name": "get_Name",
21 | "Parameters": [],
22 | "ReturnType": "System.String",
23 | "Visibility": "Public",
24 | "GenericParameter": []
25 | },
26 | {
27 | "Kind": "Method",
28 | "Name": "set_Name",
29 | "Parameters": [
30 | {
31 | "Name": "value",
32 | "Type": "System.String"
33 | }
34 | ],
35 | "ReturnType": "System.Void",
36 | "Visibility": "Public",
37 | "GenericParameter": []
38 | },
39 | {
40 | "Kind": "Constructor",
41 | "Name": ".ctor",
42 | "Parameters": [],
43 | "Visibility": "Public",
44 | "GenericParameter": []
45 | }
46 | ],
47 | "GenericParameters": []
48 | }
49 | ]
50 | }
51 |
--------------------------------------------------------------------------------
/testassets/SimpleRepo/src/Simple.Lib/breakingchanges.netcore.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "TypeId": "public class Simple.Lib.Api",
4 | "MemberId": "public System.String get_OldName()",
5 | "Kind": "Removal"
6 | }
7 | ]
8 |
--------------------------------------------------------------------------------
/testassets/SimpleRepo/src/Simple.Lib/breakingchanges.netframework.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "TypeId": "public class Simple.Lib.Api",
4 | "MemberId": "public System.String get_OldName()",
5 | "Kind": "Removal"
6 | }
7 | ]
8 |
--------------------------------------------------------------------------------
/testassets/SimpleRepo/test/Simple.Test/Simple.Test.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netcoreapp2.1;net461
5 | netcoreapp2.1
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/testassets/SimpleRepo/test/Simple.Test/UnitTest1.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using System;
5 | using Simple.Lib;
6 | using Xunit;
7 |
8 | namespace Simple.Test
9 | {
10 | public class UnitTest1
11 | {
12 | [Fact]
13 | public void Test1()
14 | {
15 | Assert.Equal("Api", new Api().Name);
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/testassets/SimpleRepo/version.props:
--------------------------------------------------------------------------------
1 |
2 |
3 | 1.0.0
4 | beta-$(BuildNumber)
5 |
6 |
7 |
--------------------------------------------------------------------------------
/tools/KoreBuild.Console/Commands/ApiBaselinesGenerateCommand.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using System.Collections.Generic;
5 | using System.IO;
6 | using Microsoft.Extensions.CommandLineUtils;
7 |
8 | namespace KoreBuild.Console.Commands
9 | {
10 | internal class ApiBaselinesGenerateCommand : SubCommandBase
11 | {
12 | public ApiBaselinesGenerateCommand(CommandContext context) : base(context)
13 | {
14 | }
15 |
16 | public override void Configure(CommandLineApplication application)
17 | {
18 | application.Description = "Generates baselines for all projects in this repo.";
19 |
20 | base.Configure(application);
21 | }
22 |
23 | protected override int Execute()
24 | {
25 | var args = new List
26 | {
27 | "msbuild",
28 | "/nologo",
29 | "/m",
30 | $"/p:KoreBuildVersion={this.Context.KoreBuildVersion}",
31 | $"/p:RepositoryRoot=\"{this.Context.RepoPath}/\"",
32 | "\"/p:GenerateBaselines=true\"",
33 | "\"/p:SkipTests=true\"",
34 | "/clp:Summary",
35 | Path.Combine(Context.KoreBuildDir, "KoreBuild.proj")
36 | };
37 |
38 | if (Reporter.IsVerbose)
39 | {
40 | args.Add("\"/v:n\"");
41 | }
42 | else
43 | {
44 | args.Add("\"/v:m\"");
45 | }
46 |
47 | return RunDotnet(args, Context.RepoPath);
48 | }
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/tools/KoreBuild.Console/Commands/CommandBase.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using Microsoft.Extensions.CommandLineUtils;
5 |
6 | namespace KoreBuild.Console.Commands
7 | {
8 | internal abstract class CommandBase
9 | {
10 | private CommandLineApplication _application;
11 |
12 | public virtual void Configure(CommandLineApplication application)
13 | {
14 | _application = application;
15 |
16 | application.HelpOption("-h|--help");
17 |
18 | application.OnExecute(
19 | () =>
20 | {
21 | if (IsValid())
22 | {
23 | return Execute();
24 | }
25 | else
26 | {
27 | application.ShowHelp();
28 | return 1;
29 | }
30 | });
31 | }
32 |
33 | protected virtual int Execute()
34 | {
35 | _application.ShowHelp();
36 |
37 | return 0;
38 | }
39 |
40 | protected virtual bool IsValid()
41 | {
42 | return true;
43 | }
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/tools/KoreBuild.Console/Commands/DockerFiles/.dockerignore:
--------------------------------------------------------------------------------
1 | korebuild-lock.txt
2 | **/bin
3 | **/obj
4 | artifacts
5 |
--------------------------------------------------------------------------------
/tools/KoreBuild.Console/Commands/DockerFiles/jessie.dockerfile:
--------------------------------------------------------------------------------
1 | FROM microsoft/dotnet:2.0-runtime-deps-jessie
2 |
3 | RUN apt-get update \
4 | && apt-get install -y --no-install-recommends \
5 | git \
6 | # KoreBuild dependencies
7 | jq \
8 | curl \
9 | unzip \
10 | apt-transport-https \
11 | && rm -rf /var/lib/apt/lists/*
12 |
13 | ADD . .
14 |
15 | ENV DOTNET_SKIP_FIRST_TIME_EXPERIENCE=true
16 |
17 | RUN ./run.sh install-tools
18 |
19 | ENTRYPOINT ["./build.sh"]
20 |
--------------------------------------------------------------------------------
/tools/KoreBuild.Console/Commands/DockerFiles/winservercore.dockerfile:
--------------------------------------------------------------------------------
1 | FROM microsoft/aspnet:4.6.2
2 |
3 |
4 | # DevPack returns exit 0 immediately, but it's not done, so we wait.
5 | # A more correct thing would be to block on a registry key existing or similar.
6 | RUN \
7 | Invoke-WebRequest https://download.microsoft.com/download/F/1/D/F1DEB8DB-D277-4EF9-9F48-3A65D4D8F965/NDP461-DevPack-KB3105179-ENU.exe -OutFile ~\\net461dev.exe ; \
8 | ~\\net461dev.exe /Passive /NoRestart ; \
9 | Start-Sleep -s 10; \
10 | Remove-Item ~\\net461dev.exe -Force ;
11 |
12 | WORKDIR c:\\repo
13 |
14 | ADD . .
15 |
16 | ENV DOTNET_SKIP_FIRST_TIME_EXPERIENCE=true
17 |
18 | RUN ./run.ps1 install-tools
19 |
20 | ENTRYPOINT ["build.cmd"]
21 |
--------------------------------------------------------------------------------
/tools/KoreBuild.Console/KoreBuild.Console.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | netcoreapp2.1
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/tools/KoreBuild.Console/Program.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using KoreBuild.Console.Commands;
5 | using Microsoft.Extensions.CommandLineUtils;
6 | using System;
7 |
8 | namespace KoreBuild.Console
9 | {
10 | class Program
11 | {
12 | static int Main(string[] args)
13 | {
14 | var application = new CommandLineApplication()
15 | {
16 | Name = "korebuild"
17 | };
18 |
19 | new RootCommand().Configure(application);
20 |
21 | try
22 | {
23 | return application.Execute(args);
24 | }
25 | catch (Exception ex)
26 | {
27 | System.Console.Error.WriteLine($"Exception thrown: '{ex.ToString()}'");
28 | return 1;
29 | }
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/tools/KoreBuild.Console/Reporter/IConsole.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using System;
5 | using System.IO;
6 |
7 | namespace Microsoft.Extensions.Tools.Internal
8 | {
9 | public interface IConsole
10 | {
11 | event ConsoleCancelEventHandler CancelKeyPress;
12 | TextWriter Out { get; }
13 | TextWriter Error { get; }
14 | TextReader In { get; }
15 | bool IsInputRedirected { get; }
16 | bool IsOutputRedirected { get; }
17 | bool IsErrorRedirected { get; }
18 | ConsoleColor ForegroundColor { get; set; }
19 | void ResetColor();
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/tools/KoreBuild.Console/Reporter/IReporter.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | namespace Microsoft.Extensions.Tools.Internal
5 | {
6 | public interface IReporter
7 | {
8 | void Verbose(string message);
9 | void Output(string message);
10 | void Warn(string message);
11 | void Error(string message);
12 | bool IsVerbose { get; }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/tools/KoreBuild.Console/Reporter/PhysicalConsole.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using System;
5 | using System.IO;
6 |
7 | namespace Microsoft.Extensions.Tools.Internal
8 | {
9 | public class PhysicalConsole : IConsole
10 | {
11 | private PhysicalConsole()
12 | {
13 | Console.CancelKeyPress += (o, e) =>
14 | {
15 | CancelKeyPress?.Invoke(o, e);
16 | };
17 | }
18 |
19 | public static IConsole Singleton { get; } = new PhysicalConsole();
20 |
21 | public event ConsoleCancelEventHandler CancelKeyPress;
22 | public TextWriter Error => Console.Error;
23 | public TextReader In => Console.In;
24 | public TextWriter Out => Console.Out;
25 | public bool IsInputRedirected => Console.IsInputRedirected;
26 | public bool IsOutputRedirected => Console.IsOutputRedirected;
27 | public bool IsErrorRedirected => Console.IsErrorRedirected;
28 | public ConsoleColor ForegroundColor
29 | {
30 | get => Console.ForegroundColor;
31 | set => Console.ForegroundColor = value;
32 | }
33 |
34 | public void ResetColor() => Console.ResetColor();
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/version.props:
--------------------------------------------------------------------------------
1 |
2 |
3 | release/2.1
4 | 2.1.7
5 | build
6 | t000
7 | $(VersionSuffix)-$(BuildNumber)
8 |
9 |
10 |
--------------------------------------------------------------------------------