-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
212 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,63 +1,67 @@ | ||
# restore-to-intellisense | ||
# Restore to intellisense | ||
|
||
Samples for the restore to intellisense demo | ||
|
||
## MSBuild intro | ||
## MSBuild | ||
|
||
* MSBuild is the build engine for .NET projects. | ||
* MSBuild uses Properties and Items to specify what and how to compile things, and what to output. Everything really evolves around targets. | ||
* MSBuild, default targets, build target. | ||
```xml | ||
<Project> | ||
|
||
6 passes | ||
<PropertyGroup> | ||
<SpecialProp>..\..\special\path\custom.dll</SpecialProp> | ||
</PropertyGroup> | ||
|
||
https://docs.microsoft.com/en-us/visualstudio/msbuild/msbuild?view=vs-2019 | ||
https://docs.microsoft.com/en-us/visualstudio/msbuild/msbuild-concepts?view=vs-2019 | ||
https://docs.microsoft.com/en-us/visualstudio/msbuild/build-process-overview?view=vs-2019#evaluation-phase | ||
<ItemGroup> | ||
<Reference Include="$(SpecialProp)" /> | ||
</ItemGroup> | ||
|
||
- 3 mins | ||
<Target Name="BeforeBuild"> | ||
<!-- Insert tasks to run before build here --> | ||
</Target> | ||
</Project> | ||
``` | ||
|
||
## Packages.config | ||
|
||
* Create a package config project, install a package. | ||
* Code against it. | ||
* Unload the project, show the reference. | ||
* Cover packages.config installation...how the build works. | ||
|
||
- 3 mins | ||
|
||
## Project System intro | ||
|
||
The project system is the interface between the project file and Visual Studio features. | ||
https://github.com/microsoft/VSProjectSystem/ | ||
https://github.com/microsoft/VSProjectSystem/blob/master/doc/overview/intro.md | ||
https://github.com/dotnet/project-system | ||
https://github.com/dotnet/project-system/tree/master/docs | ||
https://github.com/dotnet/project-system/blob/master/docs/design-time-builds.md | ||
|
||
3 mins | ||
|
||
- At this point, everyone should kind/sort of get the idea of how Visual Studio builds and how Visual Studio gets intellisense for assemblies. | ||
### MSBuild references | ||
|
||
## Packages.config vs PackageReference | ||
* [General MSBuild docs](https://docs.microsoft.com/en-us/visualstudio/msbuild/msbuild?view=vs-2019) | ||
* [MSBuild concepts](https://docs.microsoft.com/en-us/visualstudio/msbuild/msbuild-concepts?view=vs-2019) | ||
* [MSBuild evaluation](https://docs.microsoft.com/en-us/visualstudio/msbuild/build-process-overview?view=vs-2019#evaluation-phase) | ||
|
||
In packages.config the references are directly to the files. | ||
PackageReference has an assets file. | ||
## Packages.config | ||
|
||
https://github.com/dotnet/roslyn/blob/master/docs/wiki/Roslyn-Overview.md | ||
* The original NuGet package management style. | ||
* Built on basic MSBuild concepts such as `Reference`. | ||
* `Build` process is unaware of NuGet. | ||
|
||
## PackageReference Build | ||
|
||
## PackageReference build | ||
* PackageReference has an assets file, instead of hardcoding the assemblies in the project file. | ||
|
||
project.assets.json | ||
```xml | ||
<Project> | ||
... | ||
<ItemGroup> | ||
<PackageReference Include="NuGet.Common" Version="5.8.0" /> | ||
</ItemGroup> | ||
... | ||
</Project> | ||
``` | ||
|
||
https://docs.microsoft.com/en-us/visualstudio/msbuild/resolveassemblyreference-task?view=vs-2019 | ||
## Project System | ||
|
||
### Show an example with packages.config and intellisense. | ||
The project system is the interface between the project file and Visual Studio features. | ||
|
||
### Show an example with PackageReference and intellisense. (Create 2 local repos) | ||
Design time builds are minimal builds that gather enough information to populate: | ||
|
||
.... Good stopping point for some questions. | ||
* Language service (roslyn) | ||
* Solution explorer | ||
|
||
## Finally say let's learn how it works in PackageReference in details. | ||
### Project System references | ||
|
||
[CPS](https://github.com/microsoft/VSProjectSystem/) | ||
[CPS Intro](https://github.com/microsoft/VSProjectSystem/blob/master/doc/overview/intro.md) | ||
[.NET Project System](https://github.com/dotnet/project-system) | ||
[.NET Project System general docs](https://github.com/dotnet/project-system/tree/master/docs) | ||
[.NET Project System design time build details](https://github.com/dotnet/project-system/blob/master/docs/design-time-builds.md) | ||
|
||
## PackageReference, Automatic restore and `intellisense stage` in .NET Managed languages project system |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 16 | ||
VisualStudioVersion = 16.0.30803.129 | ||
MinimumVisualStudioVersion = 15.0.26124.0 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PackagesConfigProject", "src\PackagesConfigProject\PackagesConfigProject.csproj", "{EC63774E-57AD-4602-8D0D-F8A382B40793}" | ||
EndProject | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SDKPackageReferenceProject", "src\SDKPackageReferenceProject\SDKPackageReferenceProject.csproj", "{A24F12B8-E98A-471A-9746-C2C7F1C36566}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{EC63774E-57AD-4602-8D0D-F8A382B40793}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{EC63774E-57AD-4602-8D0D-F8A382B40793}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{EC63774E-57AD-4602-8D0D-F8A382B40793}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{EC63774E-57AD-4602-8D0D-F8A382B40793}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{A24F12B8-E98A-471A-9746-C2C7F1C36566}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{A24F12B8-E98A-471A-9746-C2C7F1C36566}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{A24F12B8-E98A-471A-9746-C2C7F1C36566}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{A24F12B8-E98A-471A-9746-C2C7F1C36566}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {0011730B-5B4A-4557-84E4-EEF5723BD58E} | ||
EndGlobalSection | ||
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using NuGet.Versioning; | ||
|
||
namespace PackagesConfigProject | ||
{ | ||
public class Class1 | ||
{ | ||
public void Method() | ||
{ | ||
var version = NuGetVersion.Parse("1.0.0"); | ||
|
||
System.Console.WriteLine(version); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProjectGuid>{EC63774E-57AD-4602-8D0D-F8A382B40793}</ProjectGuid> | ||
<OutputType>Library</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>PackagesConfigProject</RootNamespace> | ||
<AssemblyName>PackagesConfigProject</AssemblyName> | ||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
<Deterministic>true</Deterministic> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>bin\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\Release\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="NuGet.Versioning, Version=5.8.0.6930, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> | ||
<HintPath>..\..\packages\NuGet.Versioning.5.8.0\lib\net472\NuGet.Versioning.dll</HintPath> | ||
</Reference> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="System.Xml.Linq" /> | ||
<Reference Include="System.Data.DataSetExtensions" /> | ||
<Reference Include="Microsoft.CSharp" /> | ||
<Reference Include="System.Data" /> | ||
<Reference Include="System.Net.Http" /> | ||
<Reference Include="System.Xml" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="Class1.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Include="packages.config" /> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using System.Reflection; | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
|
||
// General Information about an assembly is controlled through the following | ||
// set of attributes. Change these attribute values to modify the information | ||
// associated with an assembly. | ||
[assembly: AssemblyTitle("PackagesConfigProject")] | ||
[assembly: AssemblyDescription("")] | ||
[assembly: AssemblyConfiguration("")] | ||
[assembly: AssemblyCompany("")] | ||
[assembly: AssemblyProduct("PackagesConfigProject")] | ||
[assembly: AssemblyCopyright("Copyright © 2021")] | ||
[assembly: AssemblyTrademark("")] | ||
[assembly: AssemblyCulture("")] | ||
|
||
// Setting ComVisible to false makes the types in this assembly not visible | ||
// to COM components. If you need to access a type in this assembly from | ||
// COM, set the ComVisible attribute to true on that type. | ||
[assembly: ComVisible(false)] | ||
|
||
// The following GUID is for the ID of the typelib if this project is exposed to COM | ||
[assembly: Guid("ec63774e-57ad-4602-8d0d-f8a382b40793")] | ||
|
||
// Version information for an assembly consists of the following four values: | ||
// | ||
// Major Version | ||
// Minor Version | ||
// Build Number | ||
// Revision | ||
// | ||
// You can specify all the values or you can default the Build and Revision Numbers | ||
// by using the '*' as shown below: | ||
// [assembly: AssemblyVersion("1.0.*")] | ||
[assembly: AssemblyVersion("1.0.0.0")] | ||
[assembly: AssemblyFileVersion("1.0.0.0")] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<packages> | ||
<package id="NuGet.Versioning" version="5.8.0" targetFramework="net472" /> | ||
</packages> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using NuGet.Versioning; | ||
using System; | ||
|
||
namespace SDKPackageReferenceProject | ||
{ | ||
class Program | ||
{ | ||
static void Main(string[] args) | ||
{ | ||
var version = NuGetVersion.Parse("1.0.0"); | ||
|
||
Console.WriteLine(version); | ||
} | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
src/SDKPackageReferenceProject/SDKPackageReferenceProject.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>netcoreapp3.1</TargetFramework> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="NuGet.Versioning" Version="5.8.0" /> | ||
</ItemGroup> | ||
|
||
</Project> |