diff --git a/.gitignore b/.gitignore index fec4dee01..1ba2c8282 100644 --- a/.gitignore +++ b/.gitignore @@ -183,4 +183,5 @@ PublishProfiles/ bower_components/ node_modules/ **/wwwroot/lib -/Msbuild.* \ No newline at end of file +/Msbuild.* +**/Nuget.exe diff --git a/.images/icon.png b/.images/icon.png new file mode 100644 index 000000000..ccd2cefad Binary files /dev/null and b/.images/icon.png differ diff --git a/.props/_GlobalStaticVersion.props b/.props/_GlobalStaticVersion.props index 5c3d65df8..e4c88a52b 100644 --- a/.props/_GlobalStaticVersion.props +++ b/.props/_GlobalStaticVersion.props @@ -11,28 +11,46 @@ Update for every public release. --> 2 - 12 + 12 0 - - beta1 + beta2 2019-09-23 + - $([MSBuild]::Divide($([System.DateTime]::Now.Subtract($([System.DateTime]::Parse($(SemanticVersionDate)))).TotalMinutes), 5).ToString('F0')) + $([MSBuild]::Divide($([System.DateTime]::Now.Subtract($([System.DateTime]::Parse($(SemanticVersionDate)))).TotalMinutes), 5).ToString('F0')) + + $(SemanticVersionMajor).$(SemanticVersionMinor).$(SemanticVersionPatch) + $(PreReleaseMilestone) + $(VersionPrefix).$(BuildNumber) + $(AssemblyVersion) - $(SemanticVersionMajor).$(SemanticVersionMinor).$(SemanticVersionPatch) + $(VersionPrefix) $(PackageVersion)-$(PreReleaseMilestone) - $(PackageVersion)-build$(PreReleaseVersion) + $(PackageVersion)-build$(BuildNumber) + + + + + <_Parameter1>$(AssemblyVersion) + + + <_Parameter1>$(FileVersion) + + diff --git a/.props/_Nupkg.props b/.props/_Nupkg.props index b09015c59..4aec5a50f 100644 --- a/.props/_Nupkg.props +++ b/.props/_Nupkg.props @@ -24,7 +24,7 @@ true MIT https://go.microsoft.com/fwlink/?LinkId=392727 - http://appanacdn.blob.core.windows.net/cdn/icons/aic.png + icon.png https://github.com/Microsoft/ApplicationInsights-dotnet Git Dependency @@ -34,6 +34,10 @@ Analytics Azure ApplicationInsights Telemetry Monitoring SDK + + + + UNDEFINED diff --git a/.scripts/release_NugetAudit.ps1 b/.scripts/release_NupkgAudit.ps1 similarity index 75% rename from .scripts/release_NugetAudit.ps1 rename to .scripts/release_NupkgAudit.ps1 index b70d65fc0..c22d41369 100644 --- a/.scripts/release_NugetAudit.ps1 +++ b/.scripts/release_NupkgAudit.ps1 @@ -4,12 +4,23 @@ # Authoring Requirements: https://microsoft.sharepoint.com/teams/NuGet/MicrosoftWiki/AuthoringRequirements.aspx # Signing Requirements: https://microsoft.sharepoint.com/teams/NuGet/MicrosoftWiki/SigningMicrosoftPackages.aspx Param( - [Parameter(Mandatory=$true,HelpMessage="Path to Artifact files (nupkg):")] + + [Parameter(Mandatory=$true,HelpMessage="Path to Nupkg files:")] [string] - $path, - [Parameter(Mandatory=$true,HelpMessage="Full Log?:")] #Include Pass with Fail output? + $nupkgPath, + + [Parameter(Mandatory=$true,HelpMessage="Path to working directory:")] + [string] + $workingDir, + + [Parameter(Mandatory=$true,HelpMessage="Full Log?:")] #Include Pass messages with output? [bool] - $verboseLog + $verboseLog, + + [Parameter(Mandatory=$false,HelpMessage="Full Log?:")] + [bool] + $verifySigning = $true + ) @@ -19,22 +30,23 @@ $expectedLicense = "MIT"; # MIT License SPDX ID $expectedOwner = "AppInsightsSdk"; # Application Insights Nuget Account $expectedTags = @("Azure","Monitoring"); +$nugetExePath = "$PSScriptRoot\Nuget.exe"; + $sb = [System.Text.StringBuilder]::new(); $script:isValid = $true; # Get the latest Nuget.exe from here: -if (!(Test-Path ".\Nuget.exe")) { +if (!(Test-Path $nugetExePath)) { Write-Host "Nuget.exe not found. Attempting download..."; Write-Host "Start time:" (Get-Date -Format G); $downloadNugetUrl = "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe"; - $saveFile = "$PSScriptRoot\Nuget.exe"; - (New-Object System.Net.WebClient).DownloadFile($downloadNugetUrl, $saveFile); + (New-Object System.Net.WebClient).DownloadFile($downloadNugetUrl, $nugetExePath); Write-Host "Finish time:" (Get-Date -Format G); - if (!(Test-Path ".\Nuget.exe")) { + if (!(Test-Path $nugetExePath)) { throw "Error: Nuget.exe not found! Please download latest from: https://www.nuget.org/downloads"; } } @@ -95,7 +107,7 @@ function Test-MultiCondition ([bool]$requiredCondition, [bool]$recommendedCondit function Get-IsPackageSigned([string]$nupkgPath) { $verifyOutput = ""; - $null = .\Nuget.exe verify -signature -CertificateFingerprint 3F9001EA83C560D712C24CF213C3D312CB3BFF51EE89435D3430BD06B5D0EECE $nupkgPath -verbosity detailed 2>&1 | Tee-Object -Variable verifyOutput + $null = & $nugetExePath verify -signature -CertificateFingerprint 3F9001EA83C560D712C24CF213C3D312CB3BFF51EE89435D3430BD06B5D0EECE $nupkgPath -verbosity detailed 2>&1 | Tee-Object -Variable verifyOutput #TEST OUTPUT Write-Host $verifyOutput @@ -137,6 +149,16 @@ function Get-DoesXmlDocExist ([string]$dllPath) { Test-Condition (Test-Path $docFile) $message $requirement; } +function Get-DoesDllVersionsMatch ([string]$dllPath) { + # CONFIRM Assembly version matches File version + [string]$fileVersion = [System.Diagnostics.FileVersionInfo]::GetVersionInfo($dllPath).FileVersion; + [string]$assemblyVersion = [Reflection.AssemblyName]::GetAssemblyName($dllPath).Version; + + $message = "File Version: '$fileVersion' Assembly Version: '$assemblyVersion"; + $requirement = "Versions should match." + Test-Condition ($fileVersion.Equals($assemblyVersion)) $message $requirement; +} + function Get-IsValidPackageId([xml]$nuspecXml) { $id = $nuspecXml.package.metadata.id; @@ -233,35 +255,23 @@ function Get-IsValidTags([xml]$nuspecXml) { } } -function Get-IsValidLogoUrl([xml]$nuspecXml, $path) { - $logoUrl = $nuspecXml.package.metadata.iconUrl; - $isEmpty = [System.String]::IsNullOrEmpty($logoUrl); - $dimension = ""; +function Get-IsValidLogo([xml]$nuspecXml, $path) { + $logoValue = $nuspecXml.package.metadata.icon; + $hasLogo = !([System.String]::IsNullOrEmpty($logoValue)); try { - $filePath = Join-Path $path "logo.png"; - $wc = New-Object System.Net.WebClient; - $wc.DownloadFile($logoUrl, $filePath); - add-type -AssemblyName System.Drawing - $png = New-Object System.Drawing.Bitmap $filePath - $dimension = "$($png.Height)x$($png.Width)"; - - # Release lock on png file - Remove-Variable png; - Remove-Variable wc; + $filePath = Join-Path $path $logoValue; + $exists = [System.IO.File]::Exists($filePath) } catch [System.SystemException] { $_.Exception.Message; } - [string[]]$expectedDimensions = ("32x32","48x48","64x64","128x128"); - - $message = "Logo Url: $logoUrl Dimensions: $dimension"; + $message1 = "Logo: $logoValue"; + $message2 = "Logo Exists: $exists"; $requirement = "Must have a logo." - $recommendation = "Should be one of these sizes: $expectedDimensions"; - $isExpected = ($expectedDimensions -contains $dimension); - - Test-MultiCondition (!$isEmpty) ($isExpected) $message $requirement $recommendation; + Test-Condition ($hasLogo) $message1 $requirement; + Test-Condition ($exists) $message2 $requirement; } function Invoke-UnZip([string]$zipfile, [string]$outpath) { @@ -273,10 +283,12 @@ function Invoke-UnZip([string]$zipfile, [string]$outpath) { function Start-EvaluateNupkg ($nupkgPath) { Write-Break; + Write-Host "Evaluate nupkg:" Write-Name $nupkgPath; - Get-IsPackageSigned $nupkgPath; - + if ($verifySigning){ + Get-IsPackageSigned $nupkgPath; + } $unzipPath = $nupkgPath+"_unzip"; Remove-Item $unzipPath -Recurse -ErrorAction Ignore @@ -284,6 +296,7 @@ function Start-EvaluateNupkg ($nupkgPath) { # LOOK FOR ALL NUSPEC WITHIN NUPKG Get-ChildItem -Path $unzipPath -Recurse -Filter *.nuspec | ForEach-Object { + Write-Host "Evaluate nuspec:" Write-Name $_.FullName; [xml]$nuspecXml = Get-Content $_.FullName Get-IsValidPackageId $nuspecXml; @@ -293,25 +306,55 @@ function Start-EvaluateNupkg ($nupkgPath) { Get-IsValidLicense $nuspecXml; Get-IsValidLicenseAcceptance $nuspecXml; Get-IsValidCopyright $nuspecXml; - Get-IsValidLogoUrl $nuspecXml $unzipPath; + Get-IsValidLogo $nuspecXml $unzipPath; Get-IsValidDescription $nuspecXml; Get-IsValidTags $nuspecXml; } # LOOK FOR ALL DLL WITHIN NUPKG Get-ChildItem -Path $unzipPath -Recurse -Filter *.dll | ForEach-Object { + Write-Host "Evaluate dll:" Write-Name $_.FullName; - Get-IsDllSigned $_.FullName; + + if ($verifySigning) { + Get-IsDllSigned $_.FullName; + } + + Get-DoesDllVersionsMatch $_.FullName; + Get-DoesXmlDocExist $_.FullName; } } -# LOOK FOR ALL NUPKG IN A DIRECTORY. -Get-ChildItem -Path $path -Recurse -Filter *.nupkg -Exclude *.symbols.nupkg | +############################ +# MAIN EXECUTION STARTS HERE +############################ + +# CLEAR WORKING DIRECTORY +Remove-Item $workingDir -Recurse -ErrorAction Ignore +New-Item -ItemType directory -Path $workingDir + +# FIND ALL NUPKG AND COPY TO WORKING DIRECTORY +Get-ChildItem -Path $nupkgPath -Recurse -Filter *.nupkg -Exclude *.symbols.nupkg -File | + Copy-Item -Destination $workingDir + +# LIST ALL FILES IN WORKING DIRECTORY +Write-Host "NUPKGS to audit:" +$files = Get-ChildItem -Path $workingDir -Recurse -File; +$files | ForEach-Object { Write-Host "`t"$_.FullName }; +Write-Host "`nCount:" $files.Count; + +# RUN AUDIT +Get-ChildItem -Path $workingDir -Recurse -File -Include *.nupkg | ForEach-Object { Start-EvaluateNupkg $_.FullName } -$sb.ToString() | Add-Content (Join-Path $path "log.txt"); +# LOG +$logPath = (Join-Path $workingDir "log.txt") +$sb.ToString() | Add-Content $logPath; +Write-Host "`nLog file created at $logPath" +# RESULT if (!$script:isValid){ - throw "NUPKG or DLL is not valid. Please review log..."; + Write-Host "`n" + throw "NUPKG or DLL is not valid. Please review log..."; } diff --git a/BASE/Directory.Build.props b/BASE/Directory.Build.props index cbfe0e9dd..d8ad69ea6 100644 --- a/BASE/Directory.Build.props +++ b/BASE/Directory.Build.props @@ -4,7 +4,6 @@ - @@ -44,7 +43,14 @@ $([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), 'EnlistmentRoot.marker')) $([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), 'SourceRoot.marker')) - $(EnlistmentRoot)\..\bin + + $(EnlistmentRoot)\.keys + $(EnlistmentRoot)\.props + $(EnlistmentRoot)\.rulesets + $(EnlistmentRoot)\.targets + + + $(EnlistmentRoot)\..\bin $([System.IO.Path]::GetFullPath( $(BinRoot) )) $(MSBuildProjectDirectory.Substring($(SourceRoot.Length))) @@ -76,6 +82,9 @@ $(BinRoot)\$(Configuration)\ETW\$(TargetFramework)\ + + + true @@ -88,16 +97,5 @@ $(IntermediateOutputPath)\AssemblyInfo.g.cs true - - - - <_Parameter1>$(SemanticVersionMajor).$(SemanticVersionMinor).$(SemanticVersionPatch).0 - - - <_Parameter1>$(SemanticVersionMajor).$(SemanticVersionMinor).$(SemanticVersionPatch).$(PreReleaseVersion) - - + \ No newline at end of file diff --git a/BASE/GlobalStaticVersion.props b/BASE/GlobalStaticVersion.props deleted file mode 100644 index 04ecce7e4..000000000 --- a/BASE/GlobalStaticVersion.props +++ /dev/null @@ -1,33 +0,0 @@ - - - - - 2 - 12 - 0 - - beta1 - - 2019-09-23 - - $([MSBuild]::Divide($([System.DateTime]::Now.Subtract($([System.DateTime]::Parse($(SemanticVersionDate)))).TotalMinutes), 5).ToString('F0')) - - - - $(SemanticVersionMajor).$(SemanticVersionMinor).$(SemanticVersionPatch) - $(PackageVersion)-$(PreReleaseMilestone) - $(PackageVersion)-build$(PreReleaseVersion) - - diff --git a/BASE/Microsoft.ApplicationInsights.sln b/BASE/Microsoft.ApplicationInsights.sln index 5f0de17ad..4c3c4bf0e 100644 --- a/BASE/Microsoft.ApplicationInsights.sln +++ b/BASE/Microsoft.ApplicationInsights.sln @@ -19,10 +19,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".Solution Items", ".Solutio Common.props = Common.props Common.targets = Common.targets Directory.Build.props = Directory.Build.props - dirs.proj = dirs.proj - GlobalStaticVersion.props = GlobalStaticVersion.props NuGet.config = NuGet.config - Nupkg.props = Nupkg.props Package.targets = Package.targets README.md = README.md Signing.props = Signing.props diff --git a/BASE/Nupkg.props b/BASE/Nupkg.props deleted file mode 100644 index 4a0be2dbf..000000000 --- a/BASE/Nupkg.props +++ /dev/null @@ -1,50 +0,0 @@ - - - - - - True - True - snupkg - - - - - - Microsoft - © Microsoft Corporation. All rights reserved. - - Microsoft - Microsoft,AppInsightsSdk - true - MIT - https://go.microsoft.com/fwlink/?LinkId=392727 - http://appanacdn.blob.core.windows.net/cdn/icons/aic.png - https://github.com/Microsoft/ApplicationInsights-dotnet - Git - Dependency - content - For the release notes please follow http://go.microsoft.com/fwlink/?LinkId=535037 - - Analytics Azure ApplicationInsights Telemetry Monitoring SDK - - - - - UNDEFINED - UNDEFINED - UNDEFINED - - - - - - false - false - false - false - false - false - - \ No newline at end of file diff --git a/BASE/dirs.proj b/BASE/dirs.proj deleted file mode 100644 index b3fe1e256..000000000 --- a/BASE/dirs.proj +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/BASE/src/Microsoft.ApplicationInsights/Microsoft.ApplicationInsights.csproj b/BASE/src/Microsoft.ApplicationInsights/Microsoft.ApplicationInsights.csproj index 395227c81..ae454fa89 100644 --- a/BASE/src/Microsoft.ApplicationInsights/Microsoft.ApplicationInsights.csproj +++ b/BASE/src/Microsoft.ApplicationInsights/Microsoft.ApplicationInsights.csproj @@ -1,6 +1,6 @@  - + net45;net46;netstandard1.3;netstandard2.0 diff --git a/BASE/src/ServerTelemetryChannel/TelemetryChannel.csproj b/BASE/src/ServerTelemetryChannel/TelemetryChannel.csproj index f8d33892e..f508204b7 100644 --- a/BASE/src/ServerTelemetryChannel/TelemetryChannel.csproj +++ b/BASE/src/ServerTelemetryChannel/TelemetryChannel.csproj @@ -1,6 +1,6 @@  - + net45;netstandard1.3;netstandard2.0 diff --git a/LOGGING/Directory.Build.props b/LOGGING/Directory.Build.props index 65a0f58eb..46456222b 100644 --- a/LOGGING/Directory.Build.props +++ b/LOGGING/Directory.Build.props @@ -4,8 +4,6 @@ - - @@ -43,8 +41,15 @@ $([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), 'EnlistmentRoot.marker')) $([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), 'SourceRoot.marker')) - - $(EnlistmentRoot)\..\bin + + + $(EnlistmentRoot)\.keys + $(EnlistmentRoot)\.props + $(EnlistmentRoot)\.rulesets + $(EnlistmentRoot)\.targets + + + $(EnlistmentRoot)\..\bin $([System.IO.Path]::GetFullPath( $(BinRoot) )) $(MSBuildProjectDirectory.Substring($(SourceRoot.Length))) @@ -73,7 +78,10 @@ $(EnlistmentRoot)\..\packages $([System.IO.Path]::GetFullPath( $(PackagesDir) )) - + + + + true @@ -90,24 +98,5 @@ $(IntermediateOutputPath)\AssemblyInfo.g.cs true - - - - - <_Parameter1>$(SemanticVersionMajor).$(SemanticVersionMinor).$(SemanticVersionPatch).0 - - - <_Parameter1>$(SemanticVersionMajor).$(SemanticVersionMinor).$(SemanticVersionPatch).$(PreReleaseVersion) - - - - - - $(SemanticVersionMajor).$(SemanticVersionMinor).$(SemanticVersionPatch).0 - $(SemanticVersionMajor).$(SemanticVersionMinor).$(SemanticVersionPatch).$(PreReleaseVersion) - - + diff --git a/LOGGING/GlobalStaticVersion.props b/LOGGING/GlobalStaticVersion.props deleted file mode 100644 index 9d2a3e075..000000000 --- a/LOGGING/GlobalStaticVersion.props +++ /dev/null @@ -1,32 +0,0 @@ - - - - - 2 - 12 - 0 - beta1 - - 2019-09-23 - - .PreReleaseVersion - $(MSBuildThisFileDirectory)$(PreReleaseVersionFileName) - - $([MSBuild]::Divide($([System.DateTime]::Now.Subtract($([System.DateTime]::Parse($(SemanticVersionDate)))).TotalMinutes), 5).ToString('F0')) - - - - $(SemanticVersionMajor).$(SemanticVersionMinor).$(SemanticVersionPatch) - $(PackageVersion)-$(PreReleaseMilestone) - $(PackageVersion)-build$(PreReleaseVersion) - - diff --git a/LOGGING/Logging.sln b/LOGGING/Logging.sln index 1702335bd..ffd06068a 100644 --- a/LOGGING/Logging.sln +++ b/LOGGING/Logging.sln @@ -18,9 +18,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".Solution Items", ".Solutio Common.props = Common.props Common.targets = Common.targets Directory.Build.props = Directory.Build.props - GlobalStaticVersion.props = GlobalStaticVersion.props NuGet.Config = NuGet.Config - Nupkg.props = Nupkg.props src\Product.props = src\Product.props README.md = README.md Signing.targets = Signing.targets diff --git a/LOGGING/Nupkg.props b/LOGGING/Nupkg.props deleted file mode 100644 index 362d70f97..000000000 --- a/LOGGING/Nupkg.props +++ /dev/null @@ -1,50 +0,0 @@ - - - - - - True - True - snupkg - - - - - - Microsoft - © Microsoft Corporation. All rights reserved. - - Microsoft - Microsoft,AppInsightsSdk - true - MIT - https://go.microsoft.com/fwlink/?LinkId=392727 - http://appanacdn.blob.core.windows.net/cdn/icons/aic.png - https://github.com/Microsoft/ApplicationInsights-dotnet-logging - Git - Dependency - content - For the release notes please follow http://go.microsoft.com/fwlink/?LinkId=535037 - - Azure Monitoring Analytics ApplicationInsights Telemetry - - - - - UNDEFINED - UNDEFINED - UNDEFINED - - - - - - false - false - false - false - false - false - - \ No newline at end of file diff --git a/LOGGING/dirs.proj b/LOGGING/dirs.proj deleted file mode 100644 index dfb56714c..000000000 --- a/LOGGING/dirs.proj +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/LOGGING/src/DiagnosticSourceListener/DiagnosticSourceListener.csproj b/LOGGING/src/DiagnosticSourceListener/DiagnosticSourceListener.csproj index 670ee67e7..7247be29a 100644 --- a/LOGGING/src/DiagnosticSourceListener/DiagnosticSourceListener.csproj +++ b/LOGGING/src/DiagnosticSourceListener/DiagnosticSourceListener.csproj @@ -6,8 +6,7 @@ - - + false diff --git a/LOGGING/src/EtwCollector/EtwCollector.csproj b/LOGGING/src/EtwCollector/EtwCollector.csproj index 686f06fe2..bc96b794c 100644 --- a/LOGGING/src/EtwCollector/EtwCollector.csproj +++ b/LOGGING/src/EtwCollector/EtwCollector.csproj @@ -6,8 +6,7 @@ - - + true true diff --git a/LOGGING/src/EventSourceListener/EventSourceListener.csproj b/LOGGING/src/EventSourceListener/EventSourceListener.csproj index 0262c2323..3ee3423c2 100644 --- a/LOGGING/src/EventSourceListener/EventSourceListener.csproj +++ b/LOGGING/src/EventSourceListener/EventSourceListener.csproj @@ -6,8 +6,7 @@ - - + true true diff --git a/LOGGING/src/ILogger/ILogger.csproj b/LOGGING/src/ILogger/ILogger.csproj index a619a6973..6915f5023 100644 --- a/LOGGING/src/ILogger/ILogger.csproj +++ b/LOGGING/src/ILogger/ILogger.csproj @@ -6,8 +6,7 @@ - - + false diff --git a/LOGGING/src/Log4NetAppender/Log4NetAppender.csproj b/LOGGING/src/Log4NetAppender/Log4NetAppender.csproj index 978fa0bf3..569276868 100644 --- a/LOGGING/src/Log4NetAppender/Log4NetAppender.csproj +++ b/LOGGING/src/Log4NetAppender/Log4NetAppender.csproj @@ -6,8 +6,7 @@ - - + true diff --git a/LOGGING/src/NLogTarget/NLogTarget.csproj b/LOGGING/src/NLogTarget/NLogTarget.csproj index 7650d64de..e2d0661d5 100644 --- a/LOGGING/src/NLogTarget/NLogTarget.csproj +++ b/LOGGING/src/NLogTarget/NLogTarget.csproj @@ -6,8 +6,7 @@ - - + true diff --git a/LOGGING/src/Product.props b/LOGGING/src/Product.props index 6ea345038..47ab6ee1e 100644 --- a/LOGGING/src/Product.props +++ b/LOGGING/src/Product.props @@ -1,6 +1,9 @@  + + + $(RelativeOutputPathBase) diff --git a/LOGGING/src/TraceListener/TraceListener.csproj b/LOGGING/src/TraceListener/TraceListener.csproj index 8a3f4c3b3..c3abc37da 100644 --- a/LOGGING/src/TraceListener/TraceListener.csproj +++ b/LOGGING/src/TraceListener/TraceListener.csproj @@ -6,8 +6,7 @@ - - + true diff --git a/NETCORE/ApplicationInsights.AspNetCore.sln b/NETCORE/ApplicationInsights.AspNetCore.sln index c19f19bdc..37880ade5 100644 --- a/NETCORE/ApplicationInsights.AspNetCore.sln +++ b/NETCORE/ApplicationInsights.AspNetCore.sln @@ -13,10 +13,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".Solution Items", ".Solutio Common.targets = Common.targets dirs.proj = dirs.proj NuGet.config = NuGet.config - Nupkg.props = Nupkg.props Readme.md = Readme.md RunTestsCore.ps1 = RunTestsCore.ps1 - SetEnv.targets = SetEnv.targets Signing.props = Signing.props EndProjectSection EndProject diff --git a/NETCORE/Directory.Build.props b/NETCORE/Directory.Build.props index 6ccdeaf5b..8a0626615 100644 --- a/NETCORE/Directory.Build.props +++ b/NETCORE/Directory.Build.props @@ -11,6 +11,13 @@ $([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), 'SourceRoot.marker')) + + $(EnlistmentRoot)\.keys + $(EnlistmentRoot)\.props + $(EnlistmentRoot)\.rulesets + $(EnlistmentRoot)\.targets + + $(EnlistmentRoot)\..\bin $([System.IO.Path]::GetFullPath( $(BinRoot) )) @@ -34,4 +41,7 @@ $([System.IO.Path]::GetFullPath( $(IntermediateOutputPath) ))\ + + + \ No newline at end of file diff --git a/NETCORE/Nupkg.props b/NETCORE/Nupkg.props deleted file mode 100644 index 8d157101b..000000000 --- a/NETCORE/Nupkg.props +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - True - True - snupkg - - - - - - Microsoft - © Microsoft Corporation. All rights reserved. - - Microsoft - Microsoft,AppInsightsSdk - true - MIT - https://go.microsoft.com/fwlink/?LinkId=392727 - https://appanacdn.blob.core.windows.net/cdn/icons/aic.png - https://github.com/Microsoft/applicationinsights-aspnetcore - Git - Dependency - content - For the release notes please follow http://go.microsoft.com/fwlink/?LinkId=535037 - - Azure;Monitoring;Analytics;ApplicationInsights;Telemetry;AppInsights; - - - - - UNDEFINED - UNDEFINED - UNDEFINED - - - - \ No newline at end of file diff --git a/NETCORE/Product.props b/NETCORE/Product.props index d3122689b..8deadeeb9 100644 --- a/NETCORE/Product.props +++ b/NETCORE/Product.props @@ -1,6 +1,6 @@ - + @@ -8,7 +8,13 @@ - 2.12.0-beta1 + + true + true + true + true + true + true \ No newline at end of file diff --git a/NETCORE/SetEnv.targets b/NETCORE/SetEnv.targets deleted file mode 100644 index 03fd9bb7c..000000000 --- a/NETCORE/SetEnv.targets +++ /dev/null @@ -1,46 +0,0 @@ - - - - - 2016-9-28 - - $([MSBuild]::Divide($([System.DateTime]::Now.Subtract($([System.DateTime]::Parse($(SemanticVersionDate)))).TotalMinutes), 5).ToString('F0')) - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/NETCORE/dirs.proj b/NETCORE/dirs.proj deleted file mode 100644 index d01213ec6..000000000 --- a/NETCORE/dirs.proj +++ /dev/null @@ -1,216 +0,0 @@ - - - - - - $(BUILD_ARTIFACTSTAGINGDIRECTORY)\dotnet-sdk-2.1.4-win-x64.zip - $(BUILD_ARTIFACTSTAGINGDIRECTORY)\dotnet-sdk-2.1.4-win-x64.latest - - .\src\Microsoft.ApplicationInsights.AspNetCore\Microsoft.ApplicationInsights.AspNetCore.csproj - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - f.ItemSpec)) - { - using (ZipArchive archive = ZipFile.OpenRead(inputFilePath)) - { - string inputFileName = Path.GetFileName(inputFilePath); - if (true == ArchiveFileNameAsRootFolder && true == Overwrite) - { - DirectoryInfo archiveDirectory = new DirectoryInfo(Path.Combine(OutputPath, inputFileName)); - if (true == archiveDirectory.Exists) - { - Log.LogMessage ("Archive root folder already exists, deleting path:{0}", archiveDirectory.FullName); - archiveDirectory.Delete(recursive: true); - } - } - - foreach (ZipArchiveEntry entry in archive.Entries) - { - string path = ArchiveFileNameAsRootFolder - ? Path.Combine(OutputPath, inputFileName, entry.FullName) - : Path.Combine(OutputPath, entry.FullName); - - FileInfo fileInfo = new FileInfo(path); - DirectoryInfo directoryInfo = new DirectoryInfo(fileInfo.DirectoryName); - if (false == directoryInfo.Exists) - { - //Log.LogMessage ("Creating directory for archive entry, path:{0}", directoryInfo.FullName); - directoryInfo.Create(); - } - - //Log.LogMessage("Extracting entry to path:{0}", path); - entry.ExtractToFile(path, Overwrite); - } - } - } - ]]> - - - - - - - - - - - - - - f.ItemSpec)) - { - Log.LogMessage("Fixing {0}", inputFilePath); - string filePath = inputFilePath; - if (filePath.EndsWith(".dll", StringComparison.OrdinalIgnoreCase)) - { - filePath = filePath.Substring(0, filePath.Length - 3) + "xml"; - } - - if (filePath.EndsWith(".xml", StringComparison.OrdinalIgnoreCase)) - { - string[] files = null; - int starIndex = filePath.IndexOf('*'); - if (starIndex >= 0) - { - string dir = filePath.Substring(0, starIndex); - if (string.IsNullOrEmpty(dir)) - { - dir = "."; - } - - string file = Path.GetFileName(filePath.Substring(starIndex)); - files = Directory.GetFiles(dir, file, SearchOption.AllDirectories); - } - else - { - files = new[] { filePath }; - } - - foreach (string fileName in files) - { - if (File.Exists(fileName)) - { - Log.LogMessage("Processing XML: {0}", fileName); - string text = File.ReadAllText(fileName); - text = text.Replace("", ""); - File.WriteAllText(fileName, text); - } - } - } - } - ]]> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Microsoft - MsSharedLib72 - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/WEB/Directory.Build.props b/WEB/Directory.Build.props index 59fe92c97..84619cb89 100644 --- a/WEB/Directory.Build.props +++ b/WEB/Directory.Build.props @@ -4,8 +4,6 @@ - - @@ -44,7 +42,14 @@ $([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), 'EnlistmentRoot.marker')) $([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), 'SourceRoot.marker')) - $(EnlistmentRoot)\..\bin + + $(EnlistmentRoot)\.keys + $(EnlistmentRoot)\.props + $(EnlistmentRoot)\.rulesets + $(EnlistmentRoot)\.targets + + + $(EnlistmentRoot)\..\bin $([System.IO.Path]::GetFullPath( $(BinRoot) )) $(MSBuildProjectDirectory.Substring($(SourceRoot.Length))) @@ -85,6 +90,9 @@ $(BinRoot)\$(Configuration)\ETW\ + + + true @@ -101,16 +109,5 @@ $(IntermediateOutputPath)\AssemblyInfo.g.cs true - - - - <_Parameter1>$(SemanticVersionMajor).$(SemanticVersionMinor).$(SemanticVersionPatch).0 - - - <_Parameter1>$(SemanticVersionMajor).$(SemanticVersionMinor).$(SemanticVersionPatch).$(PreReleaseVersion) - - + diff --git a/WEB/GlobalStaticVersion.props b/WEB/GlobalStaticVersion.props deleted file mode 100644 index 27ae9c918..000000000 --- a/WEB/GlobalStaticVersion.props +++ /dev/null @@ -1,33 +0,0 @@ - - - - - 2 - 12 - 0 - - beta1 - - 2019-09-23 - - $([MSBuild]::Divide($([System.DateTime]::Now.Subtract($([System.DateTime]::Parse($(SemanticVersionDate)))).TotalMinutes), 5).ToString('F0')) - - - - $(SemanticVersionMajor).$(SemanticVersionMinor).$(SemanticVersionPatch) - $(PackageVersion)-$(PreReleaseMilestone) - $(PackageVersion)-build$(PreReleaseVersion) - - diff --git a/WEB/Nupkg.props b/WEB/Nupkg.props deleted file mode 100644 index c363b5106..000000000 --- a/WEB/Nupkg.props +++ /dev/null @@ -1,47 +0,0 @@ - - - - - - True - True - snupkg - - - - - - Microsoft - © Microsoft Corporation. All rights reserved. - - Microsoft - Microsoft,AppInsightsSdk - true - MIT - https://go.microsoft.com/fwlink/?LinkId=392727 - http://appanacdn.blob.core.windows.net/cdn/icons/aic.png - https://github.com/Microsoft/ApplicationInsights-dotnet-server - Git - Dependency - content - - - - - UNDEFINED - UNDEFINED - UNDEFINED - UNDEFINED - - - - - false - false - false - false - false - false - - diff --git a/WEB/Src/DependencyCollector/Shared.Tests/DependencyCollector.Shared.Tests.projitems b/WEB/Src/DependencyCollector/Shared.Tests/DependencyCollector.Shared.Tests.projitems index 36ea82fa9..4af8fca82 100644 --- a/WEB/Src/DependencyCollector/Shared.Tests/DependencyCollector.Shared.Tests.projitems +++ b/WEB/Src/DependencyCollector/Shared.Tests/DependencyCollector.Shared.Tests.projitems @@ -29,6 +29,7 @@ + diff --git a/WEB/Src/DependencyCollector/Shared.Tests/Implementation/SqlClientDiagnosticSourceListenerTests.cs b/WEB/Src/DependencyCollector/Shared.Tests/Implementation/SqlClientDiagnosticSourceListenerTests.cs index 27b4bd65b..4deeca8e6 100644 --- a/WEB/Src/DependencyCollector/Shared.Tests/Implementation/SqlClientDiagnosticSourceListenerTests.cs +++ b/WEB/Src/DependencyCollector/Shared.Tests/Implementation/SqlClientDiagnosticSourceListenerTests.cs @@ -328,84 +328,6 @@ namespace Microsoft.ApplicationInsights.Tests Assert.False(dependencyTelemetry.Success.Value); } - [Theory] - [InlineData(SqlClientDiagnosticSourceListener.SqlBeforeExecuteCommand, SqlClientDiagnosticSourceListener.SqlErrorExecuteCommand)] - [InlineData(SqlClientDiagnosticSourceListener.SqlMicrosoftBeforeExecuteCommand, SqlClientDiagnosticSourceListener.SqlMicrosoftErrorExecuteCommand)] - public void TracksCommandErrorWhenSqlException(string beforeCommand, string errorCommand) - { - var operationId = Guid.NewGuid(); - var sqlConnection = new SqlConnection(TestConnectionString); - var sqlCommand = sqlConnection.CreateCommand(); - sqlCommand.CommandText = "select * from orders"; - - var beforeExecuteEventData = new - { - OperationId = operationId, - Command = sqlCommand, - Timestamp = (long?)1000000L - }; - - this.fakeSqlClientDiagnosticSource.Write( - beforeCommand, - beforeExecuteEventData); - - // Need to create SqlException via reflection because ctor is not public! - var sqlErrorCtor - = typeof(SqlError).GetConstructors(BindingFlags.NonPublic | BindingFlags.Instance) - .Single(c => c.GetParameters().Count() == 8); - - var sqlError = sqlErrorCtor.Invoke( - new object[] - { - 42, // error number - default(byte), - default(byte), - string.Empty, - string.Empty, - string.Empty, - 0, - default(Exception) - }); - - var sqlErrorCollectionCtor - = typeof(SqlErrorCollection).GetConstructors(BindingFlags.NonPublic | BindingFlags.Instance) - .Single(); - - var sqlErrorCollection = sqlErrorCollectionCtor.Invoke(new object[] { }); - - typeof(SqlErrorCollection).GetMethod("Add", BindingFlags.NonPublic | BindingFlags.Instance) - .Invoke(sqlErrorCollection, new object[] { sqlError }); - - var sqlExceptionCtor = typeof(SqlException).GetConstructors(BindingFlags.NonPublic | BindingFlags.Instance)[0]; - - var sqlException = (SqlException)sqlExceptionCtor.Invoke( - new object[] - { - "Boom!", - sqlErrorCollection, - null, - Guid.NewGuid() - }); - - var commandErrorEventData = new - { - OperationId = operationId, - Command = sqlCommand, - Exception = (Exception)sqlException, - Timestamp = 2000000L - }; - - this.fakeSqlClientDiagnosticSource.Write( - errorCommand, - commandErrorEventData); - - var dependencyTelemetry = (DependencyTelemetry)this.sendItems.Single(); - - Assert.Equal(commandErrorEventData.Exception.ToInvariantString(), dependencyTelemetry.Properties["Exception"]); - Assert.False(dependencyTelemetry.Success.Value); - Assert.Equal("42", dependencyTelemetry.ResultCode); - } - [Theory] [InlineData(SqlClientDiagnosticSourceListener.SqlBeforeOpenConnection, SqlClientDiagnosticSourceListener.SqlErrorOpenConnection)] [InlineData(SqlClientDiagnosticSourceListener.SqlMicrosoftBeforeOpenConnection, SqlClientDiagnosticSourceListener.SqlMicrosoftErrorOpenConnection)] diff --git a/WEB/Src/DependencyCollector/Shared.Tests/Implementation/SqlClientDiagnosticSourceListenerTestsCopy.cs b/WEB/Src/DependencyCollector/Shared.Tests/Implementation/SqlClientDiagnosticSourceListenerTestsCopy.cs new file mode 100644 index 000000000..e8957ed50 --- /dev/null +++ b/WEB/Src/DependencyCollector/Shared.Tests/Implementation/SqlClientDiagnosticSourceListenerTestsCopy.cs @@ -0,0 +1,170 @@ +namespace Microsoft.ApplicationInsights.Tests +{ + using System; + using System.Collections.Generic; + using System.Data; + using System.Data.SqlClient; + using System.Diagnostics; + using System.Linq; + using System.Reflection; + using Microsoft.ApplicationInsights.Channel; + using Microsoft.ApplicationInsights.DataContracts; + using Microsoft.ApplicationInsights.DependencyCollector.Implementation; + using Microsoft.ApplicationInsights.DependencyCollector.Implementation.SqlClientDiagnostics; + using Microsoft.ApplicationInsights.Extensibility; + using Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing; + using Microsoft.ApplicationInsights.W3C.Internal; + using Microsoft.ApplicationInsights.Web.TestFramework; + using Microsoft.VisualStudio.TestTools.UnitTesting; + +#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member + + [TestClass] + public class SqlClientDiagnosticSourceListenerTestsCopy : IDisposable + { + private const string TestConnectionString = "Data Source=(localdb)\\MSSQLLocalDB;Database=master"; + + private IList sendItems; + private StubTelemetryChannel stubTelemetryChannel; + private TelemetryConfiguration configuration; + private FakeSqlClientDiagnosticSource fakeSqlClientDiagnosticSource; + private SqlClientDiagnosticSourceListener sqlClientDiagnosticSourceListener; + + public SqlClientDiagnosticSourceListenerTestsCopy() + { + this.sendItems = new List(); + this.stubTelemetryChannel = new StubTelemetryChannel { OnSend = item => this.sendItems.Add(item) }; + + this.configuration = new TelemetryConfiguration + { + InstrumentationKey = Guid.NewGuid().ToString(), + TelemetryChannel = this.stubTelemetryChannel + }; + + this.fakeSqlClientDiagnosticSource = new FakeSqlClientDiagnosticSource(); + this.sqlClientDiagnosticSourceListener = new SqlClientDiagnosticSourceListener(this.configuration); + } + + public void Dispose() + { + this.sqlClientDiagnosticSourceListener.Dispose(); + this.fakeSqlClientDiagnosticSource.Dispose(); + this.configuration.Dispose(); + this.stubTelemetryChannel.Dispose(); + + while (Activity.Current != null) + { + Activity.Current.Stop(); + } + } + + /// + /// This test was failing in XUnit + Net45, so i converted it to MSTest + /// + [TestMethod] + public void TracksCommandErrorWhenSqlException_Sql() => this.RunTest(SqlClientDiagnosticSourceListener.SqlBeforeExecuteCommand, SqlClientDiagnosticSourceListener.SqlErrorExecuteCommand); + + /// + /// This test was failing in XUnit + Net45, so i converted it to MSTest + /// + [TestMethod] + public void TracksCommandErrorWhenSqlException_SqlMicrosoft() => this.RunTest(SqlClientDiagnosticSourceListener.SqlMicrosoftBeforeExecuteCommand, SqlClientDiagnosticSourceListener.SqlMicrosoftErrorExecuteCommand); + + public void RunTest(string beforeCommand, string errorCommand) + { + var operationId = Guid.NewGuid(); + var sqlConnection = new SqlConnection(TestConnectionString); + var sqlCommand = sqlConnection.CreateCommand(); + sqlCommand.CommandText = "select * from orders"; + + var beforeExecuteEventData = new + { + OperationId = operationId, + Command = sqlCommand, + Timestamp = (long?)1000000L + }; + + this.fakeSqlClientDiagnosticSource.Write( + beforeCommand, + beforeExecuteEventData); + + // Need to create SqlException via reflection because ctor is not public! + var sqlErrorCtor + = typeof(SqlError).GetConstructors(BindingFlags.NonPublic | BindingFlags.Instance) + .Single(c => c.GetParameters().Count() == 8); + + var sqlError = sqlErrorCtor.Invoke( + new object[] + { + 42, // error number + default(byte), + default(byte), + string.Empty, + string.Empty, + string.Empty, + 0, + default(Exception) + }); + + var sqlErrorCollectionCtor + = typeof(SqlErrorCollection).GetConstructors(BindingFlags.NonPublic | BindingFlags.Instance) + .Single(); + + var sqlErrorCollection = sqlErrorCollectionCtor.Invoke(new object[] { }); + + typeof(SqlErrorCollection).GetMethod("Add", BindingFlags.NonPublic | BindingFlags.Instance) + .Invoke(sqlErrorCollection, new object[] { sqlError }); + + var sqlExceptionCtor = typeof(SqlException).GetConstructors(BindingFlags.NonPublic | BindingFlags.Instance)[0]; + + var sqlException = (SqlException)sqlExceptionCtor.Invoke( + new object[] + { + "Boom!", + sqlErrorCollection, + null, + Guid.NewGuid() + }); + + var commandErrorEventData = new + { + OperationId = operationId, + Command = sqlCommand, + Exception = (Exception)sqlException, + Timestamp = 2000000L + }; + + this.fakeSqlClientDiagnosticSource.Write( + errorCommand, + commandErrorEventData); + + var dependencyTelemetry = (DependencyTelemetry)this.sendItems.Single(); + + Assert.AreEqual(commandErrorEventData.Exception.ToInvariantString(), dependencyTelemetry.Properties["Exception"]); + Assert.IsFalse(dependencyTelemetry.Success.Value); + Assert.AreEqual("42", dependencyTelemetry.ResultCode); + } + + private class FakeSqlClientDiagnosticSource : IDisposable + { + private readonly DiagnosticListener listener; + + public FakeSqlClientDiagnosticSource() + { + this.listener = new DiagnosticListener(SqlClientDiagnosticSourceListener.DiagnosticListenerName); + } + + public void Write(string name, object value) + { + this.listener.Write(name, value); + } + + public void Dispose() + { + this.listener.Dispose(); + } + } + } + +#pragma warning restore CS1591 // Missing XML comment for publicly visible type or member +} \ No newline at end of file diff --git a/WEB/Src/Microsoft.ApplicationInsights.Web.sln b/WEB/Src/Microsoft.ApplicationInsights.Web.sln index 0de0e18b1..813a8840a 100644 --- a/WEB/Src/Microsoft.ApplicationInsights.Web.sln +++ b/WEB/Src/Microsoft.ApplicationInsights.Web.sln @@ -46,9 +46,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".Solution Items", ".Solutio ..\Common.props = ..\Common.props ..\Directory.Build.props = ..\Directory.Build.props ..\dirs.proj = ..\dirs.proj - ..\GlobalStaticVersion.props = ..\GlobalStaticVersion.props ..\NuGet.config = ..\NuGet.config - ..\Nupkg.props = ..\Nupkg.props Product.props = Product.props EndProjectSection EndProject diff --git a/WEB/Src/Product.props b/WEB/Src/Product.props index 693ef097b..1c4c1bfa9 100644 --- a/WEB/Src/Product.props +++ b/WEB/Src/Product.props @@ -2,8 +2,8 @@ - - + + + $([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), 'EnlistmentRoot.marker')) + $(EnlistmentRoot)\.props + + + @@ -14,7 +21,7 @@ - +