Skip to content

Commit

Permalink
Merge pull request #36 from dotnet-campus/t/lindexi/dotnet6
Browse files Browse the repository at this point in the history
SourceFusion 尝试支持 dotnet 6 框架
  • Loading branch information
lindexi authored Feb 7, 2022
2 parents 2729e2a + 0d3a732 commit 77ca3db
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 9 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -258,4 +258,5 @@ paket-files/

# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
*.pyc
/src/SourceFusion.Tool/Properties/launchSettings.json
12 changes: 6 additions & 6 deletions src/SourceFusion.Tool/Assets/build/Package.targets
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@
<UseDotNetCore Condition=" '$(MSBuildRuntimeType)' == 'Core'">True</UseDotNetCore>
<UseDotNetCore Condition=" '$(MSBuildRuntimeType)' != 'Core'">False</UseDotNetCore>
<!-- 使用 RuntimeInformation 得到 MSBuild 此刻正在运行的 .NET 框架版本号。-->
<MSBuildRuntimeVersion Condition=" '$(UseDotNetCore)' == 'True' ">$([System.Runtime.InteropServices.RuntimeInformation]::FrameworkDescription.ToString())</MSBuildRuntimeVersion>
<_TelescopeMSBuildRuntimeFramework Condition=" $(MSBuildRuntimeVersion.StartsWith('.NET Core 3')) ">netcoreapp3.1</_TelescopeMSBuildRuntimeFramework>
<_TelescopeMSBuildRuntimeFramework Condition=" $(MSBuildRuntimeVersion.StartsWith('.NET 6')) ">net6.0</_TelescopeMSBuildRuntimeFramework>
<_TelescopeMSBuildRuntimeFramework Condition=" '$(_TelescopeMSBuildRuntimeFramework)' == '' ">net5.0</_TelescopeMSBuildRuntimeFramework>
<!--<MSBuildRuntimeVersion Condition=" '$(UseDotNetCore)' == 'True' ">$([System.Runtime.InteropServices.RuntimeInformation]::FrameworkDescription.ToString())</MSBuildRuntimeVersion>
<_TelescopeMSBuildRuntimeFramework Condition=" $(MSBuildRuntimeVersion.StartsWith('.NET Core 3')) ">netcoreapp3.1</_TelescopeMSBuildRuntimeFramework>-->
<!--<_TelescopeMSBuildRuntimeFramework Condition=" $(MSBuildRuntimeVersion.StartsWith('.NET 6')) ">net6.0</_TelescopeMSBuildRuntimeFramework>
<_TelescopeMSBuildRuntimeFramework Condition=" '$(_TelescopeMSBuildRuntimeFramework)' == '' ">net6.0</_TelescopeMSBuildRuntimeFramework>-->
</PropertyGroup>
<PropertyGroup Condition=" $(IsInDemoToolDebugMode) != 'True' ">
<TransformCodeToolCommand>&quot;$(MSBuildThisFileDirectory)../tools/net48/codet.exe&quot;</TransformCodeToolCommand>
</PropertyGroup>
<PropertyGroup Condition=" $(UseDotNetCore) == 'True' ">
<TransformCodeToolCommand>dotnet &quot;$(MSBuildThisFileDirectory)../tools/$(_TelescopeMSBuildRuntimeFramework)/codet.dll&quot;</TransformCodeToolCommand>
<TransformCodeToolCommand>dotnet &quot;$(MSBuildThisFileDirectory)../tools/netcoreapp3.1/codet.dll&quot;</TransformCodeToolCommand>
</PropertyGroup>
<PropertyGroup>
<_SourceFusionDefaultWorkingFolder Condition="'$(_SourceFusionDefaultWorkingFolder)' == ''">obj/$(Configuration)/</_SourceFusionDefaultWorkingFolder>
Expand Down Expand Up @@ -87,7 +87,7 @@
<SourceFusionRebuildRequired Condition="'$(SourceFusionRebuildRequired)' == ''">false</SourceFusionRebuildRequired>
</PropertyGroup>
<Exec ConsoleToMSBuild="True"
Command="$(TransformCodeToolCommand) &quot;$(MSBuildProjectDirectory)&quot; -t $(SourceFusionToolsFolder) -c $(SourceFusionGeneratedCodeFolder) -p &quot;$(SourceFusionProjectPropertyFile)&quot; -s &quot;$(DefineConstants)&quot; --rebuild $(SourceFusionRebuildRequired)">
Command="$(TransformCodeToolCommand) -w &quot;$(MSBuildProjectDirectory)&quot; -t $(SourceFusionToolsFolder) -c $(SourceFusionGeneratedCodeFolder) -p &quot;$(SourceFusionProjectPropertyFile)&quot; -s &quot;$(DefineConstants)&quot; --rebuild $(SourceFusionRebuildRequired)">
<Output TaskParameter="ConsoleOutput" PropertyName="_SourceFusionOutputOfGenerateCode" />
<Output TaskParameter="ExitCode" PropertyName="_SourceFusionMainExitCode" />
</Exec>
Expand Down
2 changes: 1 addition & 1 deletion src/SourceFusion.Tool/Cli/Options.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace dotnetCampus.SourceFusion.Cli
{
internal class Options
{
[Value(0, Description = "转换源码的工作路径。")]
[Value('w', Description = "转换源码的工作路径。")]
public string WorkingDirectory { get; set; }

[Option('t', "tool-folder", Description = "SourceFusion 可以使用的临时文件夹路径。")]
Expand Down
15 changes: 15 additions & 0 deletions src/SourceFusion.Tool/Core/ProjectCompilingContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,21 @@ internal class ProjectCompilingContext
internal ProjectCompilingContext(Options options)
{
// 初始化基础属性。
if (string.IsNullOrEmpty(options.WorkingDirectory))
{
throw new ArgumentNullException(nameof(options.WorkingDirectory) + $" CommandLine: {Environment.CommandLine}");
}

if (string.IsNullOrEmpty(options.ToolFolder))
{
throw new ArgumentNullException(nameof(options.ToolFolder) + $" CommandLine: {Environment.CommandLine}");
}

if (string.IsNullOrEmpty(options.GeneratedCodeFolder))
{
throw new ArgumentNullException(nameof(options.GeneratedCodeFolder) + $" CommandLine: {Environment.CommandLine}");
}

WorkingFolder = Path.GetFullPath(options.WorkingDirectory);
ToolsFolder = FullPath(options.ToolFolder);
GeneratedCodeFolder = FullPath(options.GeneratedCodeFolder);
Expand Down
8 changes: 7 additions & 1 deletion src/SourceFusion.Tool/SourceFusion.Tool.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,27 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<!-- 以下的 net6.0;net5.0 只是为了让其他项目能构建通过,不作为工具 -->
<!-- 只有 netcoreapp3.1;net48 做工具 -->
<TargetFrameworks>net6.0;net5.0;netcoreapp3.1;net48</TargetFrameworks>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<AssemblyName>codet</AssemblyName>
<RootNamespace>dotnetCampus.SourceFusion</RootNamespace>
<Product>dotnetCampus.SourceFusion</Product>
<PackageId>dotnetCampus.SourceFusion</PackageId>
<!--<GeneratePackageOnBuild>true</GeneratePackageOnBuild>-->
<Version>0.10.6-alpha</Version>
<Version>0.10.7-alpha09</Version>
<BuildOutputTargetFolder>tools</BuildOutputTargetFolder>
<Description>
使代码在编译期执行,以提升运行时效率。
SourceFusion 提供了一套编译期代码执行框架,以便将运行时可能耗时的操作提前到编译期执行。
</Description>
<LangVersion>latest</LangVersion>
<Nullable>enable</Nullable>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<!-- [Select which .NET version to use - .NET | Microsoft Docs](https://docs.microsoft.com/en-us/dotnet/core/versions/selection ) -->
<!-- 让 .NET 高版本SDK可以运行此程序,解决仅安装 .NET 6 SDK 而无法运行此基于 .NET 5 的应用 -->
<RollForward>Major</RollForward>
</PropertyGroup>

<ItemGroup>
Expand Down

0 comments on commit 77ca3db

Please sign in to comment.