Skip to content

Commit

Permalink
MSBuild Project support via 'Minsk.Sdk'
Browse files Browse the repository at this point in the history
Improved Build/Dev experience
Partial Project System support
PDB Generation is needed for visual debugging
  • Loading branch information
Nirmal4G committed May 9, 2020
1 parent f84b958 commit 80409d0
Show file tree
Hide file tree
Showing 23 changed files with 452 additions and 3 deletions.
Binary file added Minsk.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions NuGet.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<configuration>
<packageSources>
<add key="DevLocal" value="artifacts"/>
</packageSources>
</configuration>
2 changes: 2 additions & 0 deletions azure-pipelines-index.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ trigger: ['master']
pr: none

steps:
- script: mkdir artifacts
displayName: 'Create artifacts dir'
- task: DotNetCoreCLI@2
displayName: Build minsk ($(buildConfiguration))
inputs:
Expand Down
2 changes: 2 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ variables:
samples: './samples/samples.sln'

steps:
- script: mkdir artifacts
displayName: 'Create artifacts dir'
- task: DotNetCoreCLI@2
displayName: Build minsk ($(buildConfiguration))
inputs:
Expand Down
1 change: 0 additions & 1 deletion samples/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<Project>

<PropertyGroup>
<DefaultLanguageSourceExtension>.ms</DefaultLanguageSourceExtension>
<SolutionDir Condition="'$(SolutionDir)' == ''">$(MSBuildThisFileDirectory)</SolutionDir>
<RepositoryDir Condition="'$(RepositoryDir)' == ''">$([MSBuild]::NormalizeDirectory('$(MSBuildThisFileDirectory)', '..\'))</RepositoryDir>
<PublishDir>$(SolutionDir)publish</PublishDir>
Expand Down
5 changes: 5 additions & 0 deletions samples/global.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"msbuild-sdks": {
"Minsk.Sdk": "0.1.0"
}
}
2 changes: 1 addition & 1 deletion samples/hello/hello.msproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Minsk.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
Expand Down
11 changes: 10 additions & 1 deletion src/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
<Project>

<PropertyGroup>
<Features>Strict</Features>
<LangVersion>8.0</LangVersion>
<Features>strict</Features>
</PropertyGroup>

<PropertyGroup>
<SolutionDir Condition="'$(SolutionDir)' == ''">$(MSBuildThisFileDirectory)</SolutionDir>
<RepositoryDir Condition="'$(RepositoryDir)' == ''">$([MSBuild]::NormalizeDirectory('$(MSBuildThisFileDirectory)', '..\'))</RepositoryDir>
</PropertyGroup>

<ItemGroup Condition="'$(IsPackable)' == 'true'">
<Content Include="$(PackageIconPath)" Visible="false"/>
<Content Include="$(PackageLicensePath)" Visible="false"/>
</ItemGroup>

<ItemGroup Condition="'$(EnableDefaultBuildItems)' == 'true'">
<Content Include="$(DefaultBuildItemIncludes)" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder)"/>
</ItemGroup>

</Project>
29 changes: 29 additions & 0 deletions src/Directory.Build.targets
Original file line number Diff line number Diff line change
@@ -1,7 +1,36 @@
<Project>

<PropertyGroup>
<Serviceable>true</Serviceable>
<Product>Minsk Compiler</Product>
<Authors>Immo Landworth</Authors>
<PackageIcon>Minsk.png</PackageIcon>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<Copyright>Copytright © 2019 Immo Landworth</Copyright>
<PackageRequireAcceptance>false</PackageRequireAcceptance>
<RepositoryUrl>https://github.com/terrajobst/minsk</RepositoryUrl>
<PackageProjectUrl>https://github.com/terrajobst/minsk</PackageProjectUrl>
</PropertyGroup>

<PropertyGroup>
<PackageIconPath>$(RepositoryDir)$(PackageIcon)</PackageIconPath>
<PackageLicensePath>$(RepositoryDir)$(PackageLicenseFile)</PackageLicensePath>
<PackageOutputPath>$(RepositoryDir)artifacts</PackageOutputPath>
<PublishDir>$(RepositoryDir)artifacts\$(ProjectName)</PublishDir>
</PropertyGroup>

<PropertyGroup>
<EnableDefaultBuildItems Condition="'$(EnableDefaultBuildItems)' == ''">false</EnableDefaultBuildItems>
<DefaultBuildItemIncludes>**\*.props;**\*.targets;**\*.items;**\*.tasks</DefaultBuildItemIncludes>
<DefaultItemExcludes>$(DefaultItemExcludes);*.props;*.targets</DefaultItemExcludes>
</PropertyGroup>

<ItemGroup Condition="'$(IsPackable)' == 'true'">
<Content Update="@(Content)" Pack="true" PackagePath=""/>
</ItemGroup>

<ItemGroup>
<None Remove="@(Content)"/>
</ItemGroup>

</Project>
10 changes: 10 additions & 0 deletions src/Minsk.Sdk/Core/Minsk.Core.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<Project>

<PropertyGroup>
<!-- The language file extension for minsk is 'ms' -->
<DefaultLanguageSourceExtension>.ms</DefaultLanguageSourceExtension>
</PropertyGroup>

<Import Project="Minsk.ProjectSystem.props"/>

</Project>
19 changes: 19 additions & 0 deletions src/Minsk.Sdk/Core/Minsk.Core.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<Project>

<Import Project="$(MSBuildToolsPath)\Microsoft.Managed.Before.targets" Condition="Exists('$(MSBuildToolsPath)\Microsoft.Managed.Before.targets')"/>

<ImportGroup Condition="'$(IsCrossTargetingBuild)' == 'true'">
<Import Project="$(MSBuildToolsPath)\Microsoft.Common.CrossTargeting.targets"/>
<Import Project="Minsk.OuterBuild.targets"/>
</ImportGroup>

<Import Project="Minsk.ProjectSystem.targets"/>

<ImportGroup Condition="'$(IsCrossTargetingBuild)' != 'true'">
<Import Project="$(MSBuildToolsPath)\Microsoft.Common.targets"/>
<Import Project="Minsk.CoreCompile.targets"/>
</ImportGroup>

<Import Project="$(MSBuildToolsPath)\Microsoft.Managed.After.targets" Condition="Exists('$(MSBuildToolsPath)\Microsoft.Managed.After.targets')"/>

</Project>
53 changes: 53 additions & 0 deletions src/Minsk.Sdk/Core/Minsk.CoreCompile.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<Project>

<Import Project="..\Tasks\Minsk.tasks"/>

<Target Name="CreateManifestResourceNames"/>

<Target Name="GetCoreCompileInputsOutputs">
<ItemGroup>
<!-- Inputs -->
<CoreCompileInput Include="@(Compile)"/>
<CoreCompileInput Include="@(_CoreCompileResourceInputs)"/>
<CoreCompileInput Include="$(ApplicationIcon)"/>
<CoreCompileInput Include="$(AssemblyOriginatorKeyFile)"/>
<CoreCompileInput Include="@(ReferencePathWithRefAssemblies)"/>
<CoreCompileInput Include="@(CompiledLicenseFile)"/>
<CoreCompileInput Include="@(LinkResource)"/>
<CoreCompileInput Include="@(EmbeddedDocumentation)"/>
<CoreCompileInput Include="$(Win32Resource)"/>
<CoreCompileInput Include="$(Win32Manifest)"/>
<CoreCompileInput Include="@(CustomAdditionalCompileInputs)"/>
<CoreCompileInput Include="$(ResolvedCodeAnalysisRuleSet)"/>
<CoreCompileInput Include="@(AdditionalFiles)"/>
<CoreCompileInput Include="@(EmbeddedFiles)"/>
<CoreCompileInput Include="@(EditorConfigFiles)"/>
<!-- Outputs -->
<CoreCompileOutput Include="@(DocFileItem)"/>
<CoreCompileOutput Include="@(IntermediateAssembly)"/>
<CoreCompileOutput Include="@(IntermediateRefAssembly)"/>
<CoreCompileOutput Include="@(_DebugSymbolsIntermediatePath)"/>
<CoreCompileOutput Include="$(NonExistentFile)"/>
<CoreCompileOutput Include="@(CustomAdditionalCompileOutputs)"/>
</ItemGroup>
</Target>

<Target Name="CoreCompile" Inputs="@(CoreCompileInput)" Outputs="@(CoreCompileOutput)" DependsOnTargets="GetCoreCompileInputsOutputs;$(CoreCompileDependsOn)">
<MinskCompile
ToolPath="$(MinskToolsPath)"
ToolExe="$(MinskCompilerExe)"
Condition="'%(_CoreCompileResourceInputs.WithCulture)' != 'true'"
Sources="@(Compile)"
OutputAssembly="@(IntermediateAssembly)"
References="@(ReferencePathWithRefAssemblies)">
<Output TaskParameter="CommandLineArgs" ItemName="MscCommandLineArgs"/>
</MinskCompile>

<ItemGroup>
<_CoreCompileResourceInputs Remove="@(_CoreCompileResourceInputs)"/>
</ItemGroup>

<CallTarget Targets="$(TargetsTriggeredByCompilation)" Condition="'$(TargetsTriggeredByCompilation)' != ''"/>
</Target>

</Project>
29 changes: 29 additions & 0 deletions src/Minsk.Sdk/Core/Minsk.OuterBuild.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<Project>

<!--
============================================================
Publish
Multi-targeting version of Publish.
[IN]
$(TargetFrameworks) - Semicolon delimited list of target frameworks.
$(InnerTargets) - The targets to publish for each target framework.
Defaults to 'Publish' if unset, but allows override to support
`msbuild /p:InnerTargets=X;Y;Z` which will build X, Y & Z
targets for each target framework.
[OUT]
@(InnerOutput) - The combined output items of the inner targets across all builds.
============================================================
-->
<Target Name="Publish" DependsOnTargets="_SetPublishInnerTarget;DispatchToInnerBuilds"/>

<Target Name="_SetPublishInnerTarget" Returns="@(InnerOutput)">
<PropertyGroup Condition="'$(InnerTargets)' == ''">
<InnerTargets>Publish</InnerTargets>
</PropertyGroup>
</Target>

</Project>
43 changes: 43 additions & 0 deletions src/Minsk.Sdk/Core/Minsk.ProjectSystem.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<Project>

<!-- Properties -->
<PropertyGroup>
<AppDesignerFolder Condition="'$(AppDesignerFolder)' == ''">Properties</AppDesignerFolder>
<AppDesignerFolderContentsVisibleOnlyInShowAllFiles Condition="'$(AppDesignerFolderContentsVisibleOnlyInShowAllFiles)' == ''">false</AppDesignerFolderContentsVisibleOnlyInShowAllFiles>
<TemplateLanguage Condition="'$(TemplateLanguage)' == ''">Minsk</TemplateLanguage>
<LanguageServiceName Condition="'$(LanguageServiceName)' == ''">Minsk</LanguageServiceName>
<DesignerVariableNaming Condition="'$(DesignerVariableNaming)' == ''">Camel</DesignerVariableNaming>
<DesignerFunctionVisibility Condition="'$(DesignerFunctionVisibility)' == ''">Private</DesignerFunctionVisibility>
<DesignerHiddenCodeGeneration Condition="'$(DesignerHiddenCodeGeneration)' == ''">Declarations</DesignerHiddenCodeGeneration>
</PropertyGroup>

<!--
CL CPS: {13B669BE-BB05-4DDF-9536-439F39A36129}
C# CPS: {9A19103F-16F7-4668-BE54-9A1E7A4F7556}
VB CPS: {778DAE3C-4631-46EA-AA77-85C1314464D9}
F# CPS: {6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}
-->
<PropertyGroup>
<DefaultProjectTypeGuid>{13B669BE-BB05-4DDF-9536-439F39A36129}</DefaultProjectTypeGuid>
</PropertyGroup>

<!-- TODO: Replace with Minsk ProjectSystem GUIDs when developed -->
<PropertyGroup>
<LanguageServiceId Condition="'$(LanguageServiceId)'==''">$(DefaultProjectTypeGuid)</LanguageServiceId>
<AddItemTemplatesGuid Condition="'$(AddItemTemplatesGuid)' == ''">$(DefaultProjectTypeGuid)</AddItemTemplatesGuid>
<GeneratorsTypeGuid Condition="'$(GeneratorsTypeGuid)' == ''">$(DefaultProjectTypeGuid)</GeneratorsTypeGuid>
<CmdUIContextGuid Condition="'$(CmdUIContextGuid)' == ''">$(DefaultProjectTypeGuid)</CmdUIContextGuid>
</PropertyGroup>

<!-- TODO: Remove CSharp when Minsk support is added in VS -->
<PropertyGroup Condition="'$(DisableCSharpProjectSystem)' != 'true'">
<TemplateLanguage>CSharp</TemplateLanguage>
<LanguageServiceName>C#</LanguageServiceName>
<DefaultProjectTypeGuid>{9A19103F-16F7-4668-BE54-9A1E7A4F7556}</DefaultProjectTypeGuid>
<LanguageServiceId>{694DD9B6-B865-4C5B-AD85-86356E9C88DC}</LanguageServiceId>
<AddItemTemplatesGuid>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</AddItemTemplatesGuid>
<GeneratorsTypeGuid>{FAE04EC1-301F-11D3-BF4B-00C04F79EFBC}</GeneratorsTypeGuid>
<CmdUIContextGuid>{FAE04EC1-301F-11D3-BF4B-00C04F79EFBC}</CmdUIContextGuid>
</PropertyGroup>

</Project>
44 changes: 44 additions & 0 deletions src/Minsk.Sdk/Core/Minsk.ProjectSystem.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<Project>

<!-- Import design time targets for the Roslyn Project System. These are only available if Visual Studio is installed. -->
<PropertyGroup>
<DesignTimeExtensionsPath Condition="'$(DesignTimeExtensionsPath)'==''">$(MSBuildExtensionsPath)\Microsoft\VisualStudio\Managed</DesignTimeExtensionsPath>
<DesignTimeLanguageTargets Condition="'$(DesignTimeLanguageTargets)'==''">$(DesignTimeExtensionsPath)\Microsoft.Managed.DesignTime.targets</DesignTimeLanguageTargets>
</PropertyGroup>

<Import Project="$(DesignTimeLanguageTargets)" Condition="'$(DesignTimeLanguageTargets)' != '' AND Exists('$(DesignTimeLanguageTargets)')"/>

<ItemGroup>
<PropertyPageSchema Include="$(MSBuildThisFileDirectory)Rules\Minsk.ProjectItemsSchema.xaml"/>
<!-- TODO: Remove CSharp when Minsk support is added in VS -->
<ProjectCapability Include="CSharp"/>
<ProjectCapability Include="Minsk;Managed;ClassDesigner"/>
</ItemGroup>

<ItemGroup Condition="'$(DefineCommonManagedItemSchemas)' == 'true'">

<PropertyPageSchema Include="$(ManagedXamlNeutralResourcesDirectory)EditorConfigFiles.xaml">
<Context>File</Context>
</PropertyPageSchema>

<PropertyPageSchema Include="$(ManagedXamlResourcesDirectory)EditorConfigFiles.BrowseObject.xaml">
<Context>BrowseObject</Context>
</PropertyPageSchema>

</ItemGroup>

<!-- Targets -->

<!-- Returns Msc command-line arguments for the language service -->
<Target Name="CompileDesignTime"
Returns="@(_CompilerCommandLineArgs)"
DependsOnTargets="_CheckCompileDesignTimePrerequisite;Compile"
Condition="'$(IsCrossTargetingBuild)' != 'true'">

<ItemGroup>
<_CompilerCommandLineArgs Include="@(MscCommandLineArgs)"/>
</ItemGroup>

</Target>

</Project>
16 changes: 16 additions & 0 deletions src/Minsk.Sdk/Core/Rules/Minsk.ProjectItemsSchema.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<ProjectSchemaDefinitions
xmlns="http://schemas.microsoft.com/build/2009/properties">

<ContentType
Name="MinskFile"
DisplayName="Minsk file"
ItemType="Compile">
</ContentType>

<ItemType Name="Compile" DisplayName="Minsk compiler"/>
<ItemType Name="AdditionalFiles" DisplayName="Minsk analyzer additional file"/>
<ItemType Name="EditorConfigFiles" DisplayName=".editorconfig file" />

<FileExtension Name=".ms" ContentType="MinskFile"/>

</ProjectSchemaDefinitions>
37 changes: 37 additions & 0 deletions src/Minsk.Sdk/Directory.Build.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<Project>

<Import Project="..\$(MSBuildThisFile)"/>

<!-- Fix Packing Build Outputs into '<NuGetRoot>\<BuildOutputTargetFolder>[\<TfmSpecificFolder>]\*.[dll|exe|xml|pdb]' -->

<PropertyGroup>
<Nullable>Enable</Nullable>
<NoWarn>$(NoWarn);NU5100</NoWarn>
<TargetsForTfmSpecificContentInPackage>_IncludeTfmSpecificBuildOutput</TargetsForTfmSpecificContentInPackage>
</PropertyGroup>

<Target Name="_GetTfmSpecificFolder" Condition="'$(TargetFrameworks)' != ''">
<PropertyGroup>
<TfmSpecificFolder Condition="$(TargetFrameworks.Split(';').Length) == 1" />
<TfmSpecificFolder Condition="$(TargetFrameworks.Split(';').Length) > 2">$(TargetFramework.Trim('.0123456789'))</TfmSpecificFolder>
</PropertyGroup>
<PropertyGroup Condition="$(TargetFrameworks.Split(';').Length) == 2">
<TfmSpecificFolder Condition="$(TargetFramework.StartsWith('net4'))">Full</TfmSpecificFolder>
<TfmSpecificFolder Condition="$(TargetFramework.StartsWith('netcoreapp'))">Core</TfmSpecificFolder>
<TfmSpecificFolder Condition="$(TargetFramework.StartsWith('netstandard'))">Core</TfmSpecificFolder>
</PropertyGroup>
</Target>

<Target Name="_IncludeTfmSpecificBuildOutput" Condition="'$(IncludeBuildOutput)' == 'false'"
DependsOnTargets="_GetTfmSpecificFolder;BuiltProjectOutputGroup">
<PropertyGroup>
<TfmSpecificFolder Condition="'$(TargetFrameworks)' == ''" />
</PropertyGroup>
<ItemGroup>
<TfmSpecificPackageFile Include="@(BuiltProjectOutputGroupOutput->'%(FinalOutputPath)')" KeepMetadata="false">
<PackagePath>$([System.IO.Path]::Combine('$(BuildOutputTargetFolder)', '$(TfmSpecificFolder)'))</PackagePath>
</TfmSpecificPackageFile>
</ItemGroup>
</Target>

</Project>
Loading

0 comments on commit 80409d0

Please sign in to comment.