Merge remote-tracking branch 'oldcli/release/2.2.1xx' into merge-release/2.2.1xx
This commit is contained in:
commit
f3c7f5ed78
36 changed files with 760 additions and 76 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -127,6 +127,9 @@ bin/
|
|||
*.svclog
|
||||
*.scc
|
||||
|
||||
# BinLog artifacts
|
||||
msbuild.*.ProjectImports.zip
|
||||
|
||||
# Chutzpah Test files
|
||||
_Chutzpah*
|
||||
|
||||
|
|
60
Documentation/general/signing-global-tool-packages.md
Normal file
60
Documentation/general/signing-global-tool-packages.md
Normal file
|
@ -0,0 +1,60 @@
|
|||
Signing .NET Core Global Tool Packages
|
||||
===============================
|
||||
|
||||
To create a signed package for your Dotnet Tool, you will need to create a signed shim. If a shim is found in the nupkg during `dotnet tool install`, it is used instead of creating one on consumer's machine.
|
||||
|
||||
To create a signed shim, you need to add the following extra property in you project file:
|
||||
|
||||
```
|
||||
<PackAsToolShimRuntimeIdentifiers>[list of RIDs]</PackAsToolShimRuntimeIdentifiers>
|
||||
```
|
||||
|
||||
When this property is set, `dotnet pack` will generate a shim in the package (nupkg). Assuming all other other content is signed, after you sign the shim you can sign the nupkg.
|
||||
|
||||
Example:
|
||||
```xml
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>netcoreapp2.1</TargetFramework>
|
||||
<PackAsTool>true</PackAsTool>
|
||||
<PackAsToolShimRuntimeIdentifiers>win-x64;win-x86;osx-x64</PackAsToolShimRuntimeIdentifiers>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
```
|
||||
|
||||
The result nupkg will have packaged shim included. Of course `dotnet pack` does not sign the shim or the package. The mechanism for that depends on your processes. The structure of the unzipped nupkg is:
|
||||
|
||||
```
|
||||
│ shimexample.nuspec
|
||||
│ [Content_Types].xml
|
||||
│
|
||||
├───package
|
||||
│ └───services
|
||||
│ └───metadata
|
||||
│ └───core-properties
|
||||
│ 9c20d06e1d8b4a4ba3e126f30013ef32.psmdcp
|
||||
│
|
||||
├───tools
|
||||
│ └───netcoreapp2.1
|
||||
│ └───any
|
||||
│ │ DotnetToolSettings.xml
|
||||
│ │ shimexample.deps.json
|
||||
│ │ shimexample.dll
|
||||
│ │ shimexample.pdb
|
||||
│ │ shimexample.runtimeconfig.json
|
||||
│ │
|
||||
│ └───shims
|
||||
│ ├───osx-x64
|
||||
│ │ shimexample
|
||||
│ │
|
||||
│ ├───win-x64
|
||||
│ │ shimexample.exe
|
||||
│ │
|
||||
│ └───win-x86
|
||||
│ shimexample.exe
|
||||
│
|
||||
└───_rels
|
||||
.rels
|
||||
```
|
29
Documentation/general/tool-nuget-package-format.md
Normal file
29
Documentation/general/tool-nuget-package-format.md
Normal file
|
@ -0,0 +1,29 @@
|
|||
Tool NuGet package format
|
||||
-------------------------------------------
|
||||
|
||||
The most straightforward way to create a .NET tool package is to run `dotnet pack` with `PackAsTool` property set in the project file. However, if your build process is highly customized, `dotnet publish` may not create the right package for you. In this case, you can create a NuGet package for your tool using a *nuspec* file and explicitly placing assets into the NuGet package following these rules.
|
||||
|
||||
- The NuGet package has only _/tools_ folder under the root and does **not** contain any other folders; do not include folders like _/lib_, _/content_, etc.
|
||||
- Under _/tools_ folder, the subfolders must be structured with pattern _target framework short version/RID_. For example, tool assets targeting .NET core framework V2.1 that are portable across platforms should be in the folder _tools/netcoreapp2.1/any_.
|
||||
|
||||
Let's call assets under every _tools/target framework short version/RID_ combination "per TFM-RID assets" :
|
||||
- There is a DotnetToolSettings.xml for every "per TFM-RID assets".
|
||||
- The package type is DotnetTool.
|
||||
- Each set of TFM-RID assets should have all the dependencies the tool requires to run. The TFM-RID assets should work correctly after being copied via `xcopy` to another machine, assuming that machine has the correct runtime version and RID environment.
|
||||
- For portable app, there must be runtimeconfig.json for every "per TFM-RID assets".
|
||||
|
||||
# Remark:
|
||||
- Currently, only portable apps are supported so the RID must be _any_.
|
||||
- Only one tool per tool package.
|
||||
|
||||
DotnetToolSettings.xml:
|
||||
Example:
|
||||
```xml
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<DotNetCliTool>
|
||||
<Commands>
|
||||
<Command Name="%sayhello%" EntryPoint="%console.dll%" Runner="dotnet" />
|
||||
</Commands>
|
||||
</DotNetCliTool>
|
||||
```
|
||||
Currently only configurable part is command name: _sayhello_ and entry point: _console.dll_. Command Name is what the user will type in their shell to invoke the command. Entry point is the relative path to the entry dll with main.
|
|
@ -1,5 +1,9 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), testAsset.props))\testAsset.props" />
|
||||
<Project>
|
||||
|
||||
<!-- This test asset needs to import the general dir.props in order to get the SdkNugetVersion property.
|
||||
This is why it also needs to explicitly set DisableImplicitFrameworkReferences to false. -->
|
||||
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
|
||||
<Import Sdk="Microsoft.NET.Sdk" Project="Sdk.props" />
|
||||
|
||||
<PropertyGroup>
|
||||
<VersionPrefix>1.0.0-rc</VersionPrefix>
|
||||
|
@ -16,4 +20,5 @@
|
|||
<PackageReference Include="System.Linq" Version="4.3.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<Import Sdk="Microsoft.NET.Sdk" Project="Sdk.targets" />
|
||||
</Project>
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFrameworks>netcoreapp2.2</TargetFrameworks>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
|
@ -0,0 +1,12 @@
|
|||
using System;
|
||||
|
||||
namespace MultitargetedCS
|
||||
{
|
||||
class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
Console.WriteLine("Hello World!");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFrameworks>netcoreapp2.2</TargetFrameworks>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Include="Program.fs" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
|
@ -0,0 +1,8 @@
|
|||
// Learn more about F# at http://fsharp.org
|
||||
|
||||
open System
|
||||
|
||||
[<EntryPoint>]
|
||||
let main argv =
|
||||
printfn "Hello World from F#!"
|
||||
0 // return an integer exit code
|
|
@ -0,0 +1,9 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<RootNamespace>MultitargetedVB</RootNamespace>
|
||||
<TargetFrameworks>netcoreapp2.2</TargetFrameworks>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
|
@ -0,0 +1,7 @@
|
|||
Imports System
|
||||
|
||||
Module Program
|
||||
Sub Main(args As String())
|
||||
Console.WriteLine("Hello World!")
|
||||
End Sub
|
||||
End Module
|
|
@ -0,0 +1,18 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 15
|
||||
VisualStudioVersion = 15.0.26124.0
|
||||
MinimumVisualStudioVersion = 15.0.26124.0
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Debug|x64 = Debug|x64
|
||||
Debug|x86 = Debug|x86
|
||||
Release|Any CPU = Release|Any CPU
|
||||
Release|x64 = Release|x64
|
||||
Release|x86 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
|
@ -13,11 +13,18 @@
|
|||
<PackageReference Include="Microsoft.AspNetCore.App" />
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="WriteVersionsFile" BeforeTargets="Restore">
|
||||
<Target Name="WriteDefaultPatchVersionsFile" BeforeTargets="Restore">
|
||||
<WriteLinesToFile
|
||||
File="$(MSBuildThisFileDirectory)/.DefaultPatchVersionForAspNetCoreApp2_1"
|
||||
Lines="$(DefaultPatchVersionForAspNetCoreApp2_1)"
|
||||
Overwrite="true"/>
|
||||
</Target>
|
||||
|
||||
<Target Name="WriteBundledVersionsFile" BeforeTargets="Restore">
|
||||
<WriteLinesToFile
|
||||
File="$(MSBuildThisFileDirectory)/.BundledAspNetCoreVersion"
|
||||
Lines="$(MicrosoftAspNetCoreAppPackageVersion)"
|
||||
Overwrite="true"/>
|
||||
</Target>
|
||||
|
||||
|
||||
</Project>
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
<NoWarn>NU1701;NU5104</NoWarn>
|
||||
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
<MSBuildTreatWarningsAsErrors>true</MSBuildTreatWarningsAsErrors>
|
||||
|
||||
<IncludeWpfAndWinForms Condition=" '$(IncludeWpfAndWinForms)' == '' AND '$(OS)' == 'Windows_NT' ">true</IncludeWpfAndWinForms>
|
||||
<IncludeWpfAndWinForms Condition=" '$(IncludeWpfAndWinForms)' == '' ">false</IncludeWpfAndWinForms>
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<BundledTemplate Include="Microsoft.DotNet.Common.ItemTemplates" Version="$(MicrosoftDotNetCommonItemTemplatesPackageVersion)" />
|
||||
<BundledTemplate Include="Microsoft.DotNet.Common.ProjectTemplates.2.1" Version="$(MicrosoftDotNetCommonProjectTemplates20PackageVersion)" />
|
||||
<BundledTemplate Include="Microsoft.DotNet.Test.ProjectTemplates.2.1" Version="$(MicrosoftDotNetTestProjectTemplates20PackageVersion)" />
|
||||
<BundledTemplate Include="Microsoft.DotNet.Common.ProjectTemplates.2.2" Version="$(MicrosoftDotNetCommonProjectTemplates20PackageVersion)" />
|
||||
<BundledTemplate Include="Microsoft.DotNet.Test.ProjectTemplates.2.2" Version="$(MicrosoftDotNetTestProjectTemplates20PackageVersion)" />
|
||||
<BundledTemplate Include="Microsoft.Dotnet.Wpf.ProjectTemplates" Version="$(MicrosoftDotnetWpfProjectTemplatesPackageVersion)" />
|
||||
<BundledTemplate Include="Microsoft.Dotnet.WinForms.ProjectTemplates" Version="$(MicrosoftDotnetWinFormsProjectTemplatesPackageVersion)" />
|
||||
|
||||
|
|
|
@ -18,13 +18,16 @@
|
|||
|
||||
<PropertyGroup>
|
||||
<MicrosoftNETCoreAppPackageVersion>3.0.0-preview1-26909-04</MicrosoftNETCoreAppPackageVersion>
|
||||
<MicrosoftNETCoreDotNetHostResolverPackageVersion>$(MicrosoftNETCoreAppPackageVersion)</MicrosoftNETCoreDotNetHostResolverPackageVersion>
|
||||
|
||||
<!-- https://github.com/dotnet/cli/issues/9851 -->
|
||||
<MicrosoftNETCoreDotNetHostResolverPackageVersion_ForMSBuildSdkResolverOnly>3.0.0-preview1-26816-04</MicrosoftNETCoreDotNetHostResolverPackageVersion_ForMSBuildSdkResolverOnly>
|
||||
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<MicrosoftDotNetCommonItemTemplatesPackageVersion>1.0.2-beta3</MicrosoftDotNetCommonItemTemplatesPackageVersion>
|
||||
<MicrosoftDotNetCommonProjectTemplates20PackageVersion>$(MicrosoftDotNetCommonItemTemplatesPackageVersion)</MicrosoftDotNetCommonProjectTemplates20PackageVersion>
|
||||
<MicrosoftDotNetTestProjectTemplates20PackageVersion>1.0.2-beta3-20180716-1864993</MicrosoftDotNetTestProjectTemplates20PackageVersion>
|
||||
<MicrosoftDotNetCommonItemTemplatesPackageVersion>1.0.2-beta4-20180803-1918431</MicrosoftDotNetCommonItemTemplatesPackageVersion>
|
||||
<MicrosoftDotNetCommonProjectTemplates22PackageVersion>$(MicrosoftDotNetCommonItemTemplatesPackageVersion)</MicrosoftDotNetCommonProjectTemplates22PackageVersion>
|
||||
<MicrosoftDotNetTestProjectTemplates22PackageVersion>1.0.2-beta4-20180821-1966911</MicrosoftDotNetTestProjectTemplates22PackageVersion>
|
||||
|
||||
<MicroBuildCorePackageVersion>0.2.0</MicroBuildCorePackageVersion>
|
||||
<NUnit3TemplatesVersion>1.5.1</NUnit3TemplatesVersion>
|
||||
|
@ -48,7 +51,7 @@
|
|||
<PropertyGroup>
|
||||
<BuildTasksFeedToolVersion>2.1.0-prerelease-02430-04</BuildTasksFeedToolVersion>
|
||||
<VersionToolsVersion>$(BuildTasksFeedToolVersion)</VersionToolsVersion>
|
||||
<DotnetDebToolVersion>2.0.0-preview2-25331-01</DotnetDebToolVersion>
|
||||
<DotnetDebToolVersion>2.0.0</DotnetDebToolVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
<add key="linux-musl-bootstrap-feed" value="https://dotnetfeed.blob.core.windows.net/orchestrated-release-2-1/20180420-03/aspnet-inputs/index.json" />
|
||||
<add key="dotnet-msbuild" value="https://dotnet.myget.org/F/msbuild/api/v3/index.json" />
|
||||
<add key="myget-vstest" value="https://dotnet.myget.org/F/vstest/api/v3/index.json" />
|
||||
<add key="BlobFeed-2.1.3-runtime" value="https://dotnetfeed.blob.core.windows.net/orchestrated-release-2-1/20180725-02/final/index.json"/>
|
||||
]]>
|
||||
</NugetConfigCLIFeeds>
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
<TestPackagesDir>$(TestOutputDir)/packages/</TestPackagesDir>
|
||||
<TestArtifactsDir>$(TestOutputDir)/artifacts/</TestArtifactsDir>
|
||||
<TestResultXmlDir>$(TestOutputDir)/results/</TestResultXmlDir>
|
||||
<ExternalRestoreSourcesTestsContainer>$(TestArtifactsDir)/ExternalRestoreSourcesForTestsContainer.txt</ExternalRestoreSourcesTestsContainer>
|
||||
</PropertyGroup>
|
||||
|
||||
<Target Name="Test"
|
||||
|
@ -86,6 +87,12 @@
|
|||
DependsOnTargets="Init;
|
||||
SetupTestProjectData">
|
||||
<MakeDir Directories="$(TestPackagesDir)" Condition="!Exists('$(TestPackagesDir)')"/>
|
||||
<MakeDir Directories="$(TestArtifactsDir)" Condition="!Exists('$(TestArtifactsDir)')"/>
|
||||
|
||||
<WriteLinesToFile Condition="'$(ExternalRestoreSources)' != ''"
|
||||
File="$(ExternalRestoreSourcesTestsContainer)"
|
||||
Lines="<add key="PrivateBlobFeed%(NugetConfigPrivateFeeds.Identity)" value="%(NugetConfigPrivateFeeds.Identity)" />"
|
||||
Overwrite="false" />
|
||||
</Target>
|
||||
|
||||
<Target Name="RestoreTests"
|
||||
|
|
|
@ -101,15 +101,20 @@
|
|||
UseHardlinksIfPossible="False" />
|
||||
|
||||
<!-- Proactively remove all possible Shared Framework and Debian Packages -->
|
||||
<Exec Command="sudo dpkg -r $(SdkDebianPackageName)" />
|
||||
<Exec Command="sudo dpkg -r $(AspNetCoreSharedFxDebianPackageName)" />
|
||||
<Exec Command="sudo dpkg -r $(AspNetCoreSharedFxDebianPackageFileName)" />
|
||||
<Exec Command="sudo dpkg -r $(SharedFxDebianPackageName)" />
|
||||
<Exec Command="sudo dpkg -r $(SharedFxDebianPackageFileName)" />
|
||||
<Exec Command="sudo dpkg -r $(HostFxrDebianPackageName)" />
|
||||
<Exec Command="sudo dpkg -r $(HostFxrDebianPackageFileName)" />
|
||||
<Exec Command="sudo dpkg -r $(HostDebianPackageName)" />
|
||||
<Exec Command="sudo dpkg -r $(RuntimeDepsPackageName)" />
|
||||
<ItemGroup>
|
||||
<SetupDebPackageToRemove Include="$(SdkDebianPackageName)" />
|
||||
<SetupDebPackageToRemove Include="$(AspNetCoreSharedFxDebianPackageName)" />
|
||||
<SetupDebPackageToRemove Include="$(AspNetCoreSharedFxDebianPackageFileName)" />
|
||||
<SetupDebPackageToRemove Include="$(SharedFxDebianPackageName)" />
|
||||
<SetupDebPackageToRemove Include="$(SharedFxDebianPackageFileName)" />
|
||||
<SetupDebPackageToRemove Include="$(HostFxrDebianPackageName)" />
|
||||
<SetupDebPackageToRemove Include="$(HostFxrDebianPackageFileName)" />
|
||||
<SetupDebPackageToRemove Include="$(HostDebianPackageName)" />
|
||||
<SetupDebPackageToRemove Include="$(RuntimeDepsPackageName)" />
|
||||
</ItemGroup>
|
||||
<!-- The following line is needed. So it won't warning dotnet folder is not empty after uninstall -->
|
||||
<Exec Command="sudo rm -rf /usr/share/dotnet/sdk/NuGetFallbackFolder" />
|
||||
<Exec Command="!(dpkg-query -W %(SetupDebPackageToRemove.Identity)) || sudo dpkg -r %(SetupDebPackageToRemove.Identity)" />
|
||||
</Target>
|
||||
|
||||
<Target Name="TestSdkDeb"
|
||||
|
@ -139,12 +144,19 @@
|
|||
ToolPath="$(DebianInstalledDirectory)" />
|
||||
|
||||
<!-- Clean up Packages -->
|
||||
<Exec Command="sudo dpkg -r $(SdkDebianPackageName)" />
|
||||
<Exec Command="sudo dpkg -r $(AspNetCoreSharedFxDebianPackageName)" />
|
||||
<Exec Command="sudo dpkg -r $(SharedFxDebianPackageName)" />
|
||||
<Exec Command="sudo dpkg -r $(HostFxrDebianPackageName)" />
|
||||
<Exec Command="sudo dpkg -r $(HostDebianPackageName)" />
|
||||
<Exec Command="sudo dpkg -r $(RuntimeDepsPackageName)" />
|
||||
<!-- The following line is needed. So it won't warning dotnet folder is not empty after uninstall -->
|
||||
<Exec Command="sudo rm -rf /usr/share/dotnet/sdk/NuGetFallbackFolder" />
|
||||
|
||||
<ItemGroup>
|
||||
<TestSdkDebPackageToRemove Include="$(SdkDebianPackageName)" />
|
||||
<TestSdkDebPackageToRemove Include="$(AspNetCoreSharedFxDebianPackageName)" />
|
||||
<TestSdkDebPackageToRemove Include="$(SharedFxDebianPackageName)" />
|
||||
<TestSdkDebPackageToRemove Include="$(HostFxrDebianPackageName)" />
|
||||
<TestSdkDebPackageToRemove Include="$(HostDebianPackageName)" />
|
||||
<TestSdkDebPackageToRemove Include="$(RuntimeDepsPackageName)"/>
|
||||
</ItemGroup>
|
||||
<!-- If package installed remove it -->
|
||||
<Exec Command="!(dpkg-query -W %(TestSdkDebPackageToRemove.Identity)) || sudo dpkg -r %(TestSdkDebPackageToRemove.Identity)" />
|
||||
</Target>
|
||||
|
||||
<Target Name="PrepareDotnetDebDirectories">
|
||||
|
@ -184,8 +196,9 @@
|
|||
<Target Name="TestDebuild">
|
||||
<Message Text="Don't remove this" />
|
||||
|
||||
<!-- run Debuild -->
|
||||
<Exec Command="/usr/bin/env debuild -h" ContinueOnError="true">
|
||||
<!-- run Debuild -->
|
||||
<!-- NB: IgnoreExitCode prevents Exec from failing, but does not prevent us from retrieving the exit code. -->
|
||||
<Exec Command="/usr/bin/env debuild -h > /dev/null 2>&1" IgnoreExitCode="true">
|
||||
<Output TaskParameter="ExitCode" PropertyName="DebuildExitCode" />
|
||||
</Exec>
|
||||
|
||||
|
|
|
@ -197,7 +197,8 @@
|
|||
<Target Name="TestFPMTool">
|
||||
|
||||
<!-- run FPM -->
|
||||
<Exec Command="fpm --help > /dev/null" ContinueOnError="True">
|
||||
<!-- NB: IgnoreExitCode prevents Exec from failing, but does not prevent us from retrieving the exit code. -->
|
||||
<Exec Command="fpm --help > /dev/null 2>&1" IgnoreExitCode="True">
|
||||
<Output TaskParameter="ExitCode" PropertyName="FPMExitCode"/>
|
||||
</Exec>
|
||||
|
||||
|
|
|
@ -82,7 +82,38 @@ namespace Microsoft.DotNet.Build.Tasks
|
|||
|
||||
protected override MessageImportance StandardOutputLoggingImportance
|
||||
{
|
||||
get { return MessageImportance.High; } // or else the output doesn't get logged by default
|
||||
// Default is low, but we want to see output at normal verbosity.
|
||||
get { return MessageImportance.Normal; }
|
||||
}
|
||||
|
||||
protected override MessageImportance StandardErrorLoggingImportance
|
||||
{
|
||||
// This turns stderr messages into msbuild errors below.
|
||||
get { return MessageImportance.High; }
|
||||
}
|
||||
|
||||
protected override void LogEventsFromTextOutput(string singleLine, MessageImportance messageImportance)
|
||||
{
|
||||
// Crossgen's error/warning formatting is inconsistent and so we do
|
||||
// not use the "canonical error format" handling of base.
|
||||
//
|
||||
// Furthermore, we don't want to log crossgen warnings as msbuild
|
||||
// warnings because we cannot prevent them and they are only
|
||||
// occasionally formatted as something that base would recognize as
|
||||
// a canonically formatted warning anyway.
|
||||
//
|
||||
// One thing that is consistent is that crossgne errors go to stderr
|
||||
// and everything else goes to stdout. Above, we set stderr to high
|
||||
// importance above, and stdout to normal. So we can use that here
|
||||
// to distinguish between errors and messages.
|
||||
if (messageImportance == MessageImportance.High)
|
||||
{
|
||||
Log.LogError(singleLine);
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.LogMessage(messageImportance, singleLine);
|
||||
}
|
||||
}
|
||||
|
||||
protected override string GenerateFullPathToTool()
|
||||
|
|
|
@ -87,7 +87,14 @@ namespace Microsoft.DotNet.Scripts
|
|||
|
||||
if (s_config.HasVersionFragment("aspnet"))
|
||||
{
|
||||
yield return CreateRegexUpdater(dependencyVersionsPath, "MicrosoftAspNetCoreAppPackageVersion", "Microsoft.AspNetCore.App");
|
||||
yield return CreateRegexUpdater(dependencyVersionsPath, "MicrosoftAspNetCoreAllPackageVersion", "Microsoft.AspNetCore.All");
|
||||
yield return CreateRegexUpdater(dependencyVersionsPath, "DotnetEfPackageVersion", "dotnet-ef");
|
||||
yield return CreateRegexUpdater(dependencyVersionsPath, "MicrosoftAspNetCoreDeveloperCertificatesXPlatPackageVersion", "Microsoft.AspNetCore.DeveloperCertificates.XPlat");
|
||||
yield return CreateRegexUpdater(dependencyVersionsPath, "MicrosoftAspNetCoreMvcPackageVersion", "Microsoft.AspNetCore.Mvc");
|
||||
yield return CreateRegexUpdater(dependencyVersionsPath, "DotnetDevCertsPackageVersion", "dotnet-dev-certs");
|
||||
yield return CreateRegexUpdater(dependencyVersionsPath, "DotnetSqlCachePackageVersion", "dotnet-sql-cache");
|
||||
yield return CreateRegexUpdater(dependencyVersionsPath, "DotnetUserSecretsPackageVersion", "dotnet-user-secrets");
|
||||
yield return CreateRegexUpdater(dependencyVersionsPath, "DotnetWatchPackageVersion", "dotnet-watch");
|
||||
}
|
||||
if (s_config.HasVersionFragment("coresetup"))
|
||||
{
|
||||
|
|
|
@ -74,6 +74,6 @@ Resources
|
|||
<String Id="InstallationNoteTitle">Installation note</String>
|
||||
<String Id="InstallationNote">A command will be run during the install process that will improve project restore speed and enable offline access. It will take up to a minute to complete.
|
||||
</String>
|
||||
<String Id="VisualStudioWarning">If you plan to use .NET Core 2.1 with Visual Studio, Visual Studio 2017 15.7 or newer is recommended. <A HREF="https://go.microsoft.com/fwlink/?linkid=866799">Learn More</A>.
|
||||
<String Id="VisualStudioWarning">If you plan to use .NET Core 2.2 with Visual Studio, Visual Studio 2017 15.9 or newer is recommended. <A HREF="https://go.microsoft.com/fwlink/?linkid=866799">Learn More</A>.
|
||||
</String>
|
||||
</WixLocalization>
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
<Bundle Name="$(var.ProductName)" Manufacturer="$(var.Manufacturer)"
|
||||
Version="$(var.DisplayVersion)" UpgradeCode="$(var.UpgradeCode)"
|
||||
AboutUrl="http://dotnet.github.io/"
|
||||
AboutUrl="https://dotnet.github.io/"
|
||||
Compressed="yes">
|
||||
|
||||
<BootstrapperApplicationRef Id="WixStandardBootstrapperApplication.Foundation">
|
||||
|
|
|
@ -76,6 +76,9 @@ $env:DOTNET_MULTILEVEL_LOOKUP=0
|
|||
# Turn off MSBuild Node re-use
|
||||
$env:MSBUILDDISABLENODEREUSE=1
|
||||
|
||||
# Workaround for the sockets issue when restoring with many nuget feeds.
|
||||
$env:DOTNET_SYSTEM_NET_HTTP_USESOCKETSHTTPHANDLER=0
|
||||
|
||||
# Enable vs test console logging
|
||||
$env:VSTEST_BUILD_TRACE=1
|
||||
$env:VSTEST_TRACE_BUILD=1
|
||||
|
@ -109,7 +112,7 @@ if ($NoBuild)
|
|||
}
|
||||
else
|
||||
{
|
||||
dotnet msbuild build.proj /p:Architecture=$Architecture /p:GeneratePropsFile=true /t:WriteDynamicPropsToStaticPropsFiles $ExtraParametersNoTargets
|
||||
dotnet msbuild build.proj /m /v:normal /fl /flp:v=diag /bl /p:Architecture=$Architecture $ExtraParameters
|
||||
dotnet msbuild build.proj /bl:msbuild.generatepropsfile.binlog /p:Architecture=$Architecture /p:GeneratePropsFile=true /t:WriteDynamicPropsToStaticPropsFiles $ExtraParametersNoTargets
|
||||
dotnet msbuild build.proj /bl:msbuild.generatepropsfile.binlog /m /v:normal /fl /flp:v=diag /bl /p:Architecture=$Architecture $ExtraParameters
|
||||
if($LASTEXITCODE -ne 0) { throw "Failed to build" }
|
||||
}
|
||||
|
|
|
@ -156,6 +156,9 @@ export DOTNET_MULTILEVEL_LOOKUP=0
|
|||
# Turn off MSBuild Node re-use
|
||||
export MSBUILDDISABLENODEREUSE=1
|
||||
|
||||
# Workaround for the sockets issue when restoring with many nuget feeds.
|
||||
export DOTNET_SYSTEM_NET_HTTP_USESOCKETSHTTPHANDLER=0
|
||||
|
||||
# Install a stage 0
|
||||
INSTALL_ARCHITECTURE=$ARCHITECTURE
|
||||
archlower="$(echo $ARCHITECTURE | awk '{print tolower($0)}')"
|
||||
|
@ -191,8 +194,8 @@ fi
|
|||
export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
|
||||
|
||||
if [ $BUILD -eq 1 ]; then
|
||||
dotnet msbuild build.proj /p:Architecture=$ARCHITECTURE $CUSTOM_BUILD_ARGS /p:GeneratePropsFile=true /t:WriteDynamicPropsToStaticPropsFiles ${argsnotargets[@]}
|
||||
dotnet msbuild build.proj /m /v:normal /fl /flp:v=diag /bl /p:Architecture=$ARCHITECTURE $CUSTOM_BUILD_ARGS $args
|
||||
dotnet msbuild build.proj /bl:msbuild.generatepropsfile.binlog /p:Architecture=$ARCHITECTURE $CUSTOM_BUILD_ARGS /p:GeneratePropsFile=true /t:WriteDynamicPropsToStaticPropsFiles ${argsnotargets[@]}
|
||||
dotnet msbuild build.proj /bl:msbuild.mainbuild.binlog /m /v:normal /fl /flp:v=diag /bl /p:Architecture=$ARCHITECTURE $CUSTOM_BUILD_ARGS $args
|
||||
else
|
||||
echo "Not building due to --nobuild"
|
||||
echo "Command that would be run is: 'dotnet msbuild build.proj /m /p:Architecture=$ARCHITECTURE $CUSTOM_BUILD_ARGS $args'"
|
||||
|
|
|
@ -4,47 +4,16 @@
|
|||
#
|
||||
|
||||
# Dockerfile that creates a container suitable to build dotnet-cli
|
||||
FROM debian:jessie
|
||||
FROM microsoft/dotnet-buildtools-prereqs:debian-8.2-debpkg-d770b8b-20180628122423
|
||||
|
||||
# Misc Dependencies for build
|
||||
RUN apt-get update && \
|
||||
RUN rm -rf /var/lib/apt/lists/* && \
|
||||
apt-get update && \
|
||||
apt-get -qqy install \
|
||||
curl \
|
||||
unzip \
|
||||
gettext \
|
||||
sudo && \
|
||||
apt-get clean && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# This could become a "microsoft/coreclr" image, since it just installs the dependencies for CoreCLR (and stdlib)
|
||||
RUN apt-get update &&\
|
||||
apt-get -qqy install \
|
||||
libunwind8 \
|
||||
libkrb5-3 \
|
||||
libicu52 \
|
||||
liblttng-ust0 \
|
||||
libssl1.0.0 \
|
||||
zlib1g \
|
||||
libuuid1 && \
|
||||
apt-get clean && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Install Build Prereqs
|
||||
RUN apt-get update && \
|
||||
apt-get -qqy install \
|
||||
debhelper \
|
||||
build-essential \
|
||||
devscripts \
|
||||
git \
|
||||
cmake \
|
||||
clang-3.5 && \
|
||||
apt-get clean && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Use clang as c++ compiler
|
||||
RUN update-alternatives --install /usr/bin/c++ c++ /usr/bin/clang++-3.5 100
|
||||
RUN update-alternatives --set c++ /usr/bin/clang++-3.5
|
||||
|
||||
# Setup User to match Host User, and give superuser permissions
|
||||
ARG USER_ID=0
|
||||
RUN useradd -m code_executor -u ${USER_ID} -g sudo
|
||||
|
|
135
src/Microsoft.DotNet.MSBuildSdkResolver/Interop.cs
Normal file
135
src/Microsoft.DotNet.MSBuildSdkResolver/Interop.cs
Normal file
|
@ -0,0 +1,135 @@
|
|||
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
namespace Microsoft.DotNet.MSBuildSdkResolver
|
||||
{
|
||||
internal static partial class Interop
|
||||
{
|
||||
internal static readonly bool RunningOnWindows =
|
||||
#if NET46
|
||||
// Not using RuntimeInformation on NET46 to avoid non-in-box framework API,
|
||||
// which create deployment problems for the resolver.
|
||||
Path.DirectorySeparatorChar == '\\';
|
||||
#else
|
||||
RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
|
||||
#endif
|
||||
|
||||
static Interop()
|
||||
{
|
||||
if (RunningOnWindows)
|
||||
{
|
||||
PreloadWindowsLibrary("hostfxr.dll");
|
||||
}
|
||||
}
|
||||
|
||||
// MSBuild SDK resolvers are required to be AnyCPU, but we have a native dependency and .NETFramework does not
|
||||
// have a built-in facility for dynamically loading user native dlls for the appropriate platform. We therefore
|
||||
// preload the version with the correct architecture (from a corresponding sub-folder relative to us) on static
|
||||
// construction so that subsequent P/Invokes can find it.
|
||||
private static void PreloadWindowsLibrary(string dllFileName)
|
||||
{
|
||||
string basePath = Path.GetDirectoryName(typeof(Interop).Assembly.Location);
|
||||
string architecture = IntPtr.Size == 8 ? "x64" : "x86";
|
||||
string dllPath = Path.Combine(basePath, architecture, dllFileName);
|
||||
|
||||
// return value is intentially ignored as we let the subsequent P/Invokes fail naturally.
|
||||
LoadLibraryExW(dllPath, IntPtr.Zero, LOAD_WITH_ALTERED_SEARCH_PATH);
|
||||
}
|
||||
|
||||
// lpFileName passed to LoadLibraryEx must be a full path.
|
||||
private const int LOAD_WITH_ALTERED_SEARCH_PATH = 0x8;
|
||||
|
||||
[DllImport("kernel32.dll", CharSet = CharSet.Unicode, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)]
|
||||
private static extern IntPtr LoadLibraryExW(string lpFileName, IntPtr hFile, int dwFlags);
|
||||
|
||||
|
||||
[Flags]
|
||||
internal enum hostfxr_resolve_sdk2_flags_t : int
|
||||
{
|
||||
disallow_prerelease = 0x1,
|
||||
}
|
||||
|
||||
internal enum hostfxr_resolve_sdk2_result_key_t : int
|
||||
{
|
||||
resolved_sdk_dir = 0,
|
||||
global_json_path = 1,
|
||||
}
|
||||
|
||||
internal static class Windows
|
||||
{
|
||||
private const CharSet UTF16 = CharSet.Unicode;
|
||||
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl, CharSet = UTF16)]
|
||||
internal delegate void hostfxr_resolve_sdk2_result_fn(
|
||||
hostfxr_resolve_sdk2_result_key_t key,
|
||||
string value);
|
||||
|
||||
[DllImport("hostfxr", CharSet = UTF16, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
|
||||
internal static extern int hostfxr_resolve_sdk2(
|
||||
string exe_dir,
|
||||
string working_dir,
|
||||
hostfxr_resolve_sdk2_flags_t flags,
|
||||
hostfxr_resolve_sdk2_result_fn result);
|
||||
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl, CharSet = UTF16)]
|
||||
internal delegate void hostfxr_get_available_sdks_result_fn(
|
||||
int sdk_count,
|
||||
[MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)]
|
||||
string[] sdk_dirs);
|
||||
|
||||
[DllImport("hostfxr", CharSet = UTF16, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
|
||||
internal static extern int hostfxr_get_available_sdks(
|
||||
string exe_dir,
|
||||
hostfxr_get_available_sdks_result_fn result);
|
||||
}
|
||||
|
||||
internal static class Unix
|
||||
{
|
||||
// Ansi marhsaling on Unix is actually UTF8
|
||||
private const CharSet UTF8 = CharSet.Ansi;
|
||||
private static string PtrToStringUTF8(IntPtr ptr) => Marshal.PtrToStringAnsi(ptr);
|
||||
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl, CharSet = UTF8)]
|
||||
internal delegate void hostfxr_resolve_sdk2_result_fn(
|
||||
hostfxr_resolve_sdk2_result_key_t key,
|
||||
string value);
|
||||
|
||||
[DllImport("hostfxr", CharSet = UTF8, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
|
||||
internal static extern int hostfxr_resolve_sdk2(
|
||||
string exe_dir,
|
||||
string working_dir,
|
||||
hostfxr_resolve_sdk2_flags_t flags,
|
||||
hostfxr_resolve_sdk2_result_fn result);
|
||||
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl, CharSet = UTF8)]
|
||||
internal delegate void hostfxr_get_available_sdks_result_fn(
|
||||
int sdk_count,
|
||||
[MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)]
|
||||
string[] sdk_dirs);
|
||||
|
||||
[DllImport("hostfxr", CharSet = UTF8, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
|
||||
internal static extern int hostfxr_get_available_sdks(
|
||||
string exe_dir,
|
||||
hostfxr_get_available_sdks_result_fn result);
|
||||
|
||||
[DllImport("libc", CharSet = UTF8, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
|
||||
private static extern IntPtr realpath(string path, IntPtr buffer);
|
||||
|
||||
[DllImport("libc", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
|
||||
private static extern void free(IntPtr ptr);
|
||||
|
||||
internal static string realpath(string path)
|
||||
{
|
||||
var ptr = realpath(path, IntPtr.Zero);
|
||||
var result = PtrToStringUTF8(ptr);
|
||||
free(ptr);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,76 @@
|
|||
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace Microsoft.DotNet.MSBuildSdkResolver
|
||||
{
|
||||
internal static class NETCoreSdkResolver
|
||||
{
|
||||
public sealed class Result
|
||||
{
|
||||
/// <summary>
|
||||
/// Path to .NET Core SDK selected by hostfxr (e.g. C:\Program Files\dotnet\sdk\2.1.300).
|
||||
/// </summary>
|
||||
public string ResolvedSdkDirectory;
|
||||
|
||||
/// <summary>
|
||||
/// Path to global.json file that impacted resolution.
|
||||
/// </summary>
|
||||
public string GlobalJsonPath;
|
||||
|
||||
public void Initialize(Interop.hostfxr_resolve_sdk2_result_key_t key, string value)
|
||||
{
|
||||
switch (key)
|
||||
{
|
||||
case Interop.hostfxr_resolve_sdk2_result_key_t.resolved_sdk_dir:
|
||||
ResolvedSdkDirectory = value;
|
||||
break;
|
||||
case Interop.hostfxr_resolve_sdk2_result_key_t.global_json_path:
|
||||
GlobalJsonPath = value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static Result ResolveSdk(
|
||||
string dotnetExeDirectory,
|
||||
string globalJsonStartDirectory,
|
||||
bool disallowPrerelease = false)
|
||||
{
|
||||
var result = new Result();
|
||||
var flags = disallowPrerelease ? Interop.hostfxr_resolve_sdk2_flags_t.disallow_prerelease : 0;
|
||||
|
||||
int errorCode = Interop.RunningOnWindows
|
||||
? Interop.Windows.hostfxr_resolve_sdk2(dotnetExeDirectory, globalJsonStartDirectory, flags, result.Initialize)
|
||||
: Interop.Unix.hostfxr_resolve_sdk2(dotnetExeDirectory, globalJsonStartDirectory, flags, result.Initialize);
|
||||
|
||||
Debug.Assert((errorCode == 0) == (result.ResolvedSdkDirectory != null));
|
||||
return result;
|
||||
}
|
||||
|
||||
private sealed class SdkList
|
||||
{
|
||||
public string[] Entries;
|
||||
|
||||
public void Initialize(int count, string[] entries)
|
||||
{
|
||||
entries = entries ?? Array.Empty<string>();
|
||||
Debug.Assert(count == entries.Length);
|
||||
Entries = entries;
|
||||
}
|
||||
}
|
||||
|
||||
public static string[] GetAvailableSdks(string dotnetExeDirectory)
|
||||
{
|
||||
var list = new SdkList();
|
||||
|
||||
int errorCode = Interop.RunningOnWindows
|
||||
? Interop.Windows.hostfxr_get_available_sdks(dotnetExeDirectory, list.Initialize)
|
||||
: Interop.Unix.hostfxr_get_available_sdks(dotnetExeDirectory, list.Initialize);
|
||||
|
||||
return list.Entries;
|
||||
}
|
||||
}
|
||||
}
|
155
src/Microsoft.DotNet.MSBuildSdkResolver/VSSettings.cs
Normal file
155
src/Microsoft.DotNet.MSBuildSdkResolver/VSSettings.cs
Normal file
|
@ -0,0 +1,155 @@
|
|||
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
#if NET46
|
||||
using Microsoft.VisualStudio.Setup.Configuration;
|
||||
#endif
|
||||
|
||||
namespace Microsoft.DotNet.MSBuildSdkResolver
|
||||
{
|
||||
internal sealed class VSSettings
|
||||
{
|
||||
private readonly object _lock = new object();
|
||||
private readonly string _settingsFilePath;
|
||||
private readonly bool _disallowPrereleaseByDefault;
|
||||
private FileInfo _settingsFile;
|
||||
private bool _disallowPrerelease;
|
||||
|
||||
// In the product, this singleton is used. It must be safe to use in parallel on multiple threads.
|
||||
// In tests, mock instances can be created with the test constructor below.
|
||||
public static readonly VSSettings Ambient = new VSSettings();
|
||||
|
||||
private VSSettings()
|
||||
{
|
||||
#if NET46
|
||||
if (!Interop.RunningOnWindows)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
string instanceId;
|
||||
string installationVersion;
|
||||
bool isPrerelease;
|
||||
|
||||
try
|
||||
{
|
||||
var configuration = new SetupConfiguration();
|
||||
var instance = configuration.GetInstanceForCurrentProcess();
|
||||
|
||||
instanceId = instance.GetInstanceId();
|
||||
installationVersion = instance.GetInstallationVersion();
|
||||
isPrerelease = ((ISetupInstanceCatalog)instance).IsPrerelease();
|
||||
}
|
||||
catch (COMException)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var version = Version.Parse(installationVersion);
|
||||
|
||||
_settingsFilePath = Path.Combine(
|
||||
Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
|
||||
"Microsoft",
|
||||
"VisualStudio",
|
||||
version.Major + ".0_" + instanceId,
|
||||
"sdk.txt");
|
||||
|
||||
_disallowPrereleaseByDefault = !isPrerelease;
|
||||
_disallowPrerelease = _disallowPrereleaseByDefault;
|
||||
#endif
|
||||
}
|
||||
|
||||
// Test constructor
|
||||
public VSSettings(string settingsFilePath, bool disallowPrereleaseByDefault)
|
||||
{
|
||||
_settingsFilePath = settingsFilePath;
|
||||
_disallowPrereleaseByDefault = disallowPrereleaseByDefault;
|
||||
_disallowPrerelease = _disallowPrereleaseByDefault;
|
||||
}
|
||||
|
||||
public bool DisallowPrerelease()
|
||||
{
|
||||
if (_settingsFilePath != null)
|
||||
{
|
||||
Refresh();
|
||||
}
|
||||
|
||||
return _disallowPrerelease;
|
||||
}
|
||||
|
||||
private void Refresh()
|
||||
{
|
||||
Debug.Assert(_settingsFilePath != null);
|
||||
|
||||
var file = new FileInfo(_settingsFilePath);
|
||||
|
||||
// NB: All calls to Exists and LastWriteTimeUtc below will not hit the disk
|
||||
// They will return data obtained during Refresh() here.
|
||||
file.Refresh();
|
||||
|
||||
lock (_lock)
|
||||
{
|
||||
// File does not exist -> use default.
|
||||
if (!file.Exists)
|
||||
{
|
||||
_disallowPrerelease = _disallowPrereleaseByDefault;
|
||||
_settingsFile = file;
|
||||
return;
|
||||
}
|
||||
|
||||
// File has not changed -> reuse prior read.
|
||||
if (_settingsFile?.Exists == true && file.LastWriteTimeUtc <= _settingsFile.LastWriteTimeUtc)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// File has changed -> read from disk
|
||||
// If we encounter an I/O exception, assume writer is in the process of updating file,
|
||||
// ignore the exception, and use stale settings until the next resolution.
|
||||
try
|
||||
{
|
||||
ReadFromDisk();
|
||||
_settingsFile = file;
|
||||
return;
|
||||
}
|
||||
catch (IOException) { }
|
||||
catch (UnauthorizedAccessException) { }
|
||||
}
|
||||
}
|
||||
|
||||
private void ReadFromDisk()
|
||||
{
|
||||
using (var reader = new StreamReader(_settingsFilePath))
|
||||
{
|
||||
string line;
|
||||
while ((line = reader.ReadLine()) != null)
|
||||
{
|
||||
int indexOfEquals = line.IndexOf('=');
|
||||
if (indexOfEquals < 0 || indexOfEquals == (line.Length - 1))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
string key = line.Substring(0, indexOfEquals).Trim();
|
||||
string value = line.Substring(indexOfEquals + 1).Trim();
|
||||
|
||||
if (key.Equals("UsePreviews", StringComparison.OrdinalIgnoreCase)
|
||||
&& bool.TryParse(value, out bool usePreviews))
|
||||
{
|
||||
_disallowPrerelease = !usePreviews;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// File does not have UsePreviews entry -> use default
|
||||
_disallowPrerelease = _disallowPrereleaseByDefault;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
23
src/dotnet/ToolPackage/PackageLocation.cs
Normal file
23
src/dotnet/ToolPackage/PackageLocation.cs
Normal file
|
@ -0,0 +1,23 @@
|
|||
|
||||
using System;
|
||||
using Microsoft.Extensions.EnvironmentAbstractions;
|
||||
|
||||
namespace Microsoft.DotNet.ToolPackage
|
||||
{
|
||||
internal class PackageLocation
|
||||
{
|
||||
public PackageLocation(
|
||||
FilePath? nugetConfig = null,
|
||||
DirectoryPath? rootConfigDirectory = null,
|
||||
string[] additionalFeeds = null)
|
||||
{
|
||||
NugetConfig = nugetConfig;
|
||||
RootConfigDirectory = rootConfigDirectory;
|
||||
AdditionalFeeds = additionalFeeds ?? Array.Empty<string>();
|
||||
}
|
||||
|
||||
public FilePath? NugetConfig { get; }
|
||||
public DirectoryPath? RootConfigDirectory { get; }
|
||||
public string[] AdditionalFeeds { get; }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
using Microsoft.DotNet.Cli.CommandLine;
|
||||
using LocalizableStrings = Microsoft.DotNet.Tools.Restore.LocalizableStrings;
|
||||
|
||||
|
||||
namespace Microsoft.DotNet.Cli
|
||||
{
|
||||
internal static class ToolCommandRestorePassThroughOptions
|
||||
{
|
||||
public static Option DisableParallelOption()
|
||||
{
|
||||
return Create.Option(
|
||||
"--disable-parallel",
|
||||
LocalizableStrings.CmdDisableParallelOptionDescription,
|
||||
Accept.NoArguments().ForwardAs("--disable-parallel"));
|
||||
}
|
||||
|
||||
public static Option NoCacheOption()
|
||||
{
|
||||
return Create.Option(
|
||||
"--no-cache",
|
||||
LocalizableStrings.CmdNoCacheOptionDescription,
|
||||
Accept.NoArguments().ForwardAs("--no-cache"));
|
||||
}
|
||||
|
||||
public static Option IgnoreFailedSourcesOption()
|
||||
{
|
||||
return Create.Option(
|
||||
"--ignore-failed-sources",
|
||||
LocalizableStrings.CmdIgnoreFailedSourcesOptionDescription,
|
||||
Accept.NoArguments().ForwardAs("--ignore-failed-sources"));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -52,7 +52,7 @@ namespace EndToEnd
|
|||
var bundledVersion = File.ReadAllText(bundledVersionPath).Trim();
|
||||
|
||||
restoredVersion.ToNormalizedString().Should().BeEquivalentTo(bundledVersion,
|
||||
"The bundled aspnetcore versions set in Microsoft.NETCoreSdk.BundledVersions.props should be idenitical to the versions set in DependencyVersions.props." +
|
||||
"The bundled aspnetcore versions set in Microsoft.NETCoreSdk.BundledVersions.props should be identical to the versions generated." +
|
||||
"Please update MSBuildExtensions.targets in this repo so these versions match.");
|
||||
}
|
||||
|
||||
|
@ -98,7 +98,7 @@ namespace EndToEnd
|
|||
var bundledVersion = File.ReadAllText(bundledVersionPath).Trim();
|
||||
|
||||
restoredVersion.ToNormalizedString().Should().BeEquivalentTo(bundledVersion,
|
||||
"The bundled aspnetcore versions set in Microsoft.NETCoreSdk.BundledVersions.props should be idenitical to the versions set in DependencyVersions.props." +
|
||||
"The bundled aspnetcore versions set in Microsoft.NETCoreSdk.BundledVersions.props should be identical to the versions set in DependencyVersions.props." +
|
||||
"Please update MSBuildExtensions.targets in this repo so these versions match.");
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,8 @@ namespace EndToEnd
|
|||
"1.0",
|
||||
"1.1",
|
||||
"2.0",
|
||||
"2.1"
|
||||
"2.1",
|
||||
"2.2"
|
||||
}.Select(version => new object[] { version });
|
||||
}
|
||||
}
|
||||
|
|
|
@ -109,19 +109,23 @@ namespace Microsoft.DotNet.TestFramework
|
|||
return this;
|
||||
}
|
||||
|
||||
public TestAssetInstance WithNuGetConfig(string nugetCache)
|
||||
public TestAssetInstance WithNuGetConfig(string nugetCache, string externalRestoreSources = null)
|
||||
{
|
||||
var thisAssembly = typeof(TestAssetInstance).GetTypeInfo().Assembly;
|
||||
var newNuGetConfig = Root.GetFile("NuGet.Config");
|
||||
externalRestoreSources = externalRestoreSources ?? string.Empty;
|
||||
|
||||
var content = @"<?xml version=""1.0"" encoding=""utf-8""?>
|
||||
<configuration>
|
||||
<packageSources>
|
||||
<add key=""dotnet-core"" value=""https://dotnetfeed.blob.core.windows.net/dotnet-core/index.json"" />
|
||||
<add key=""test-packages"" value=""$fullpath$"" />
|
||||
$externalRestoreSources$
|
||||
</packageSources>
|
||||
</configuration>";
|
||||
content = content.Replace("$fullpath$", nugetCache);
|
||||
content = content
|
||||
.Replace("$fullpath$", nugetCache)
|
||||
.Replace("$externalRestoreSources$", externalRestoreSources);
|
||||
|
||||
using (var newNuGetConfigStream =
|
||||
new FileStream(newNuGetConfig.FullName, FileMode.Create, FileAccess.Write))
|
||||
|
|
|
@ -22,6 +22,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
|
|||
private string _stage2WithBackwardsCompatibleRuntimesDirectory;
|
||||
private string _testPackages;
|
||||
private string _testWorkingFolder;
|
||||
private string _testArtifactsFolder;
|
||||
|
||||
public static string RepoRoot
|
||||
{
|
||||
|
@ -92,6 +93,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
|
|||
public string Stage2WithBackwardsCompatibleRuntimesDirectory => _stage2WithBackwardsCompatibleRuntimesDirectory;
|
||||
public string TestPackages => _testPackages;
|
||||
public string TestWorkingFolder => _testWorkingFolder;
|
||||
public string TestArtifactsFolder => _testArtifactsFolder;
|
||||
|
||||
public RepoDirectoriesProvider(
|
||||
string artifacts = null,
|
||||
|
@ -123,6 +125,8 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
|
|||
_testPackages = Path.Combine(_artifacts, "test", "packages");
|
||||
}
|
||||
|
||||
_testArtifactsFolder = Path.Combine(_artifacts, "test", "artifacts");
|
||||
|
||||
_testWorkingFolder = Path.Combine(RepoRoot,
|
||||
"bin",
|
||||
(previousStage + 1).ToString(),
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Linq;
|
||||
using Microsoft.DotNet.Cli.Utils;
|
||||
using Microsoft.DotNet.TestFramework;
|
||||
using Microsoft.DotNet.Tools.Common;
|
||||
|
||||
namespace Microsoft.DotNet.Tools.Test.Utilities
|
||||
{
|
||||
public static class TestAssetInstanceExtensions
|
||||
{
|
||||
public static TestAssetInstance WithNuGetConfigAndExternalRestoreSources(
|
||||
this TestAssetInstance testAssetInstance, string nugetCache)
|
||||
{
|
||||
var externalRestoreSourcesForTests = Path.Combine(
|
||||
new RepoDirectoriesProvider().TestArtifactsFolder, "ExternalRestoreSourcesForTestsContainer.txt");
|
||||
var externalRestoreSources = File.Exists(externalRestoreSourcesForTests) ?
|
||||
File.ReadAllText(externalRestoreSourcesForTests) :
|
||||
string.Empty;
|
||||
|
||||
return testAssetInstance.WithNuGetConfig(nugetCache, externalRestoreSources);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue