Skip to content

Commit 38f34df

Browse files
authored
Merge pull request #1 from dotnet-campus/t/walterlv/large-address-aware
Add LargeAddressAware for 32-bit applications including .NET Core AppHost.
2 parents 91d4ad4 + d0ff8e9 commit 38f34df

19 files changed

+309
-0
lines changed

.github/workflows/dotnet-build.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: .NET Build
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
build:
7+
8+
runs-on: windows-latest
9+
10+
steps:
11+
- uses: actions/checkout@v1
12+
13+
- name: Build with dotnet
14+
run: dotnet build --configuration Release
15+
16+
- name: Test
17+
run: dotnet test --configuration Release
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# 去掉注释可以合并 master 分支自动打包
2+
# 为什么不期望推送 master 自动打包?原因是打出来的 CBB 没有 Tag 不利于回滚找到代码
3+
4+
# name: publish nuget
5+
6+
# on:
7+
# push:
8+
# branches:
9+
# - master
10+
11+
# jobs:
12+
# build:
13+
14+
# runs-on: windows-latest
15+
16+
# steps:
17+
# - uses: actions/checkout@v1
18+
19+
# - name: Setup .NET Core
20+
# uses: actions/setup-dotnet@v1
21+
# with:
22+
# dotnet-version: 3.1.300
23+
24+
# - name: Build with dotnet
25+
# run: |
26+
# dotnet build --configuration Release
27+
# dotnet pack --configuration Release --no-build
28+
29+
# - name: Install Nuget
30+
# uses: nuget/setup-nuget@v1
31+
# with:
32+
# nuget-version: '5.x'
33+
34+
# - name: Add private GitHub registry to NuGet
35+
# run: |
36+
# nuget sources add -name github -Source https://nuget.pkg.github.com/dotnet-campus/index.json -Username dotnet-campus -Password ${{ secrets.GITHUB_TOKEN }}
37+
# - name: Push generated package to GitHub registry
38+
# run: |
39+
# nuget push .\bin\Release\*.nupkg -Source github -SkipDuplicate
40+
# nuget push .\bin\Release\*.nupkg -Source https://api.nuget.org/v3/index.json -SkipDuplicate -ApiKey ${{ secrets.NugetKey }}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: publish nuget
2+
3+
on:
4+
push:
5+
tags:
6+
- '*'
7+
8+
jobs:
9+
build:
10+
11+
runs-on: windows-latest
12+
13+
steps:
14+
- uses: actions/checkout@v1
15+
16+
- name: Install dotnet tool
17+
run: dotnet tool install -g dotnetCampus.TagToVersion
18+
19+
- name: Set tag to version
20+
run: dotnet TagToVersion -t ${{ github.ref }}
21+
22+
- name: Build with dotnet
23+
run: |
24+
dotnet build --configuration Release
25+
dotnet pack --configuration Release --no-build
26+
27+
- name: Install Nuget
28+
uses: nuget/setup-nuget@v1
29+
with:
30+
nuget-version: '5.x'
31+
32+
- name: Add private GitHub registry to NuGet
33+
run: |
34+
nuget sources add -name github -Source https://nuget.pkg.github.com/dotnet-campus/index.json -Username dotnet-campus -Password ${{ secrets.GITHUB_TOKEN }}
35+
36+
- name: Push generated package to GitHub registry
37+
run: |
38+
nuget push .\bin\Release\*.nupkg -Source github -SkipDuplicate
39+
nuget push .\bin\Release\*.nupkg -Source https://api.nuget.org/v3/index.json -SkipDuplicate -ApiKey ${{ secrets.NugetKey }}

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# dotnetCampus.LargeAddressAware

Directory.Build.props

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<Project>
2+
<Import Project="build\Version.props" />
3+
<PropertyGroup>
4+
<LangVersion>latest</LangVersion>
5+
<PackageOutputPath>$(MSBuildThisFileDirectory)bin\$(Configuration)</PackageOutputPath>
6+
<Company>dotnet campus(.NET 职业技术学院)</Company>
7+
8+
<Authors>dotnet-campus</Authors>
9+
<RepositoryUrl>https://github.com/dotnet-campus/dotnetCampus.LargeAddressAware</RepositoryUrl>
10+
<PackageProjectUrl>https://github.com/dotnet-campus/dotnetCampus.LargeAddressAware</PackageProjectUrl>
11+
<Description>The dotnetCampus.LargeAddressAware is a MSBuild task to edit the final 32-bit application so that it can handle addresses larger than 2 gigabytes. In a 64-bit application, this is enabled by default.</Description>
12+
13+
<RepositoryType>git</RepositoryType>
14+
<Copyright>Copyright © 2021 dotnet campus, All Rights Reserved.</Copyright>
15+
</PropertyGroup>
16+
</Project>

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# dotnetCampus.LargeAddressAware
2+
3+
| Build | NuGet |
4+
|--|--|
5+
|![](https://github.com/dotnet-campus/dotnetCampus.LargeAddressAware/workflows/.NET%20Build/badge.svg)|[![](https://img.shields.io/nuget/v/dotnetCampus.LargeAddressAware.svg)](https://www.nuget.org/packages/dotnetCampus.LargeAddressAware)|

build/Version.props

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<Project>
2+
<PropertyGroup>
3+
<Version>1.0.0</Version>
4+
</PropertyGroup>
5+
</Project>

dotnetCampus.LargeAddressAware.sln

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.1.31911.260
5+
MinimumVisualStudioVersion = 15.0.26124.0
6+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "dotnetCampus.LargeAddressAware", "src\dotnetCampus.LargeAddressAware\dotnetCampus.LargeAddressAware.csproj", "{F7ED61F4-920C-49EB-8DC1-74B2BE6AF272}"
7+
EndProject
8+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{CE019A82-6C68-41E0-967D-D0025E708D14}"
9+
ProjectSection(SolutionItems) = preProject
10+
CHANGELOG.md = CHANGELOG.md
11+
Directory.Build.props = Directory.Build.props
12+
.github\workflows\dotnet-build.yml = .github\workflows\dotnet-build.yml
13+
.github\workflows\nuget-master-publish.yml = .github\workflows\nuget-master-publish.yml
14+
.github\workflows\nuget-tag-publish.yml = .github\workflows\nuget-tag-publish.yml
15+
README.md = README.md
16+
build\Version.props = build\Version.props
17+
EndProjectSection
18+
EndProject
19+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "dotnetCampus.LargeAddressAware.Sample", "samples\dotnetCampus.LargeAddressAware.Sample\dotnetCampus.LargeAddressAware.Sample.csproj", "{866AA27F-5C03-47CD-A7FF-0CCD91A0E722}"
20+
EndProject
21+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{327603CF-14C8-4CFD-8EC6-3DB93195A0EC}"
22+
EndProject
23+
Global
24+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
25+
Debug|Any CPU = Debug|Any CPU
26+
Release|Any CPU = Release|Any CPU
27+
EndGlobalSection
28+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
29+
{F7ED61F4-920C-49EB-8DC1-74B2BE6AF272}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
30+
{F7ED61F4-920C-49EB-8DC1-74B2BE6AF272}.Debug|Any CPU.Build.0 = Debug|Any CPU
31+
{F7ED61F4-920C-49EB-8DC1-74B2BE6AF272}.Release|Any CPU.ActiveCfg = Release|Any CPU
32+
{F7ED61F4-920C-49EB-8DC1-74B2BE6AF272}.Release|Any CPU.Build.0 = Release|Any CPU
33+
{866AA27F-5C03-47CD-A7FF-0CCD91A0E722}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
34+
{866AA27F-5C03-47CD-A7FF-0CCD91A0E722}.Debug|Any CPU.Build.0 = Debug|Any CPU
35+
{866AA27F-5C03-47CD-A7FF-0CCD91A0E722}.Release|Any CPU.ActiveCfg = Release|Any CPU
36+
{866AA27F-5C03-47CD-A7FF-0CCD91A0E722}.Release|Any CPU.Build.0 = Release|Any CPU
37+
EndGlobalSection
38+
GlobalSection(SolutionProperties) = preSolution
39+
HideSolutionNode = FALSE
40+
EndGlobalSection
41+
GlobalSection(NestedProjects) = preSolution
42+
{866AA27F-5C03-47CD-A7FF-0CCD91A0E722} = {327603CF-14C8-4CFD-8EC6-3DB93195A0EC}
43+
EndGlobalSection
44+
GlobalSection(ExtensibilityGlobals) = postSolution
45+
SolutionGuid = {D5CD64F2-E3D6-4B45-A6B6-5CA19C8AD681}
46+
EndGlobalSection
47+
EndGlobal
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using System;
2+
3+
namespace dotnetCampus.LargeAddressAware.Sample
4+
{
5+
internal class Program
6+
{
7+
static void Main(string[] args)
8+
{
9+
Console.WriteLine("Hello World!");
10+
}
11+
}
12+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<Import Project="..\..\src\dotnetCampus.LargeAddressAware\Assets\build\PackageId.props" />
4+
5+
<PropertyGroup>
6+
<OutputType>Exe</OutputType>
7+
<TargetFrameworks>net5.0;net48</TargetFrameworks>
8+
<PlatformTarget>x86</PlatformTarget>
9+
</PropertyGroup>
10+
11+
<Import Project="..\..\src\dotnetCampus.LargeAddressAware\Assets\build\PackageId.targets" />
12+
13+
</Project>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<Project>
2+
3+
<PropertyGroup>
4+
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
5+
</PropertyGroup>
6+
7+
<PropertyGroup>
8+
<!-- LargeAddressAware is enabled by default. -->
9+
<LargeAddressAware>true</LargeAddressAware>
10+
</PropertyGroup>
11+
12+
</Project>
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<Project>
2+
3+
<PropertyGroup>
4+
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
5+
<dotnetCampus_LargeAddressAware_Root>$(MSBuildThisFileDirectory)..\</dotnetCampus_LargeAddressAware_Root>
6+
<dotnetCampus_LargeAddressAware_EditBin>$(dotnetCampus_LargeAddressAware_Root)tools\EditBin\editbin.exe</dotnetCampus_LargeAddressAware_EditBin>
7+
</PropertyGroup>
8+
9+
<Target Name="dotnetCampus_LargeAddressAware_PrepareProperties">
10+
<PropertyGroup>
11+
<dotnetCampus_LargeAddressAware_ShouldEditBin Condition="
12+
$(LargeAddressAware) == true
13+
And $(DesignTimeBuild) != true
14+
And ($(OutputType) == Exe Or $(OutputType) == WinExe)
15+
And $(PlatformTarget) == x86
16+
">true</dotnetCampus_LargeAddressAware_ShouldEditBin>
17+
<dotnetCampus_LargeAddressAware_ShouldEditBin Condition=" '$(dotnetCampus_LargeAddressAware_ShouldEditBin)' == '' ">false</dotnetCampus_LargeAddressAware_ShouldEditBin>
18+
<dotnetCampus_LargeAddressAware_FinalExeFile Condition="$(UseAppHost) == true">$(AppHostIntermediatePath)</dotnetCampus_LargeAddressAware_FinalExeFile>
19+
<dotnetCampus_LargeAddressAware_FinalExeFile Condition="$(UseAppHost) != true">@(IntermediateAssembly)</dotnetCampus_LargeAddressAware_FinalExeFile>
20+
</PropertyGroup>
21+
<Warning Condition=" $(OutputType) != Exe And $(OutputType) != WinExe " Text="生成的程序不是 exe,因此无法开启大内存感知(LargeAddressAware)。" />
22+
<Message Importance="high" Condition=" $(PlatformTarget) == x86 " Text="生成的程序不是 x86 架构,因此无需开启大内存感知(LargeAddressAware)。" />
23+
<Message Condition=" $(LargeAddressAware) != true " Text="已通过 LargeAddressAware 属性禁用了 x86 应用程序的大内存感知(LargeAddressAware)。" />
24+
</Target>
25+
26+
<Target Name="dotnetCampus_LargeAddressAware_EditBin"
27+
DependsOnTargets="dotnetCampus_LargeAddressAware_PrepareProperties">
28+
<Error Condition=" $(dotnetCampus_LargeAddressAware_ShouldEditBin)
29+
And !Exists('$(dotnetCampus_LargeAddressAware_FinalExeFile)') "
30+
Text="无法开启大内存感知(LargeAddressAware),因为文件“$(dotnetCampus_LargeAddressAware_FinalExeFile)”不存在。" />
31+
<Exec Condition=" $(dotnetCampus_LargeAddressAware_ShouldEditBin) == true "
32+
Command="$(dotnetCampus_LargeAddressAware_EditBin) /largeaddressaware &quot;$(dotnetCampus_LargeAddressAware_FinalExeFile)&quot;" />
33+
</Target>
34+
35+
<!-- .NET Core 的大内存感知 -->
36+
<Target Name="dotnetCampus_LargeAddressAware_EditAppHost"
37+
AfterTargets="_CreateAppHost">
38+
<CallTarget Condition="$(UseAppHost) == true" Targets="dotnetCampus_LargeAddressAware_EditBin" />
39+
</Target>
40+
41+
<!-- .NET Framework 的大内存感知 -->
42+
<Target Name="dotnetCampus_LargeAddressAware_EditAssemblyFile"
43+
AfterTargets="CoreCompile">
44+
<CallTarget Condition="$(UseAppHost) != true" Targets="dotnetCampus_LargeAddressAware_EditBin" />
45+
</Target>
46+
47+
</Project>
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace dotnetCampus.LargeAddressAware
2+
{
3+
internal static class Program
4+
{
5+
private static void Main()
6+
{
7+
}
8+
}
9+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFrameworks>netcoreapp3.0;net40</TargetFrameworks>
6+
<AssemblyName>dlaa</AssemblyName>
7+
<PackageId>dotnetCampus.LargeAddressAware</PackageId>
8+
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
9+
<IsTool>true</IsTool>
10+
</PropertyGroup>
11+
12+
<!-- 在 GitHub 的 Action 构建会添加 GITHUB_ACTIONS 变量 -->
13+
<!-- 下面进行自动构建,自动添加源代码链接等 -->
14+
<!-- 详细请看 https://github.com/dotnet/sourcelink -->
15+
<PropertyGroup Condition="'$(GITHUB_ACTIONS)' == 'true'">
16+
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
17+
18+
<!-- Optional: Publish the repository URL in the built .nupkg (in the NuSpec <Repository> element) -->
19+
<PublishRepositoryUrl>true</PublishRepositoryUrl>
20+
21+
<!-- 只有在 GitHub 的 Action 构建才能使用源代码链接 -->
22+
<!-- 源代码链接需要使用 commit 号,而在 GitHub 的 Action 构建的 commit 才是对的 -->
23+
<!-- 本地构建,也许没有记得 commit 就构建,此时的 nuget 包的源代码是不对的,上传上去会让调试诡异 -->
24+
<!-- Optional: Embed source files that are not tracked by the source control manager in the PDB -->
25+
<EmbedUntrackedSources>true</EmbedUntrackedSources>
26+
27+
<!-- 本地等不需要创建符号文件 -->
28+
<!-- Optional: Build symbol package (.snupkg) to distribute the PDB containing Source Link -->
29+
<IncludeSymbols>true</IncludeSymbols>
30+
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
31+
</PropertyGroup>
32+
33+
<ItemGroup>
34+
<!-- 链接源代码到 GitHub 仓库,方便调试 -->
35+
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" />
36+
</ItemGroup>
37+
38+
<Target Name="IncludeAllDependencies" BeforeTargets="_GetPackageFiles">
39+
<ItemGroup>
40+
<None Include="Assets\build\PackageId.props" Pack="True" PackagePath="build\$(PackageId).props" />
41+
<None Include="Assets\build\PackageId.targets" Pack="True" PackagePath="build\$(PackageId).targets" />
42+
<None Include="Assets\tools\**\*.*" Pack="True" PackagePath="tools" />
43+
</ItemGroup>
44+
</Target>
45+
46+
</Project>

0 commit comments

Comments
 (0)