Skip to content

Commit 4fc7680

Browse files
committed
Migrating project versions.
1 parent aa1e92c commit 4fc7680

1 file changed

Lines changed: 4 additions & 72 deletions

File tree

source/Makefile

Lines changed: 4 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -540,81 +540,13 @@ $(BUILD_DIR)$(PROJECT_DIR)%.zip: $(PROJECT_DIR)%.zip
540540
@rsync -av $(subst $(BUILD_DIR),,$@) $@
541541

542542
$(PROJECT_DIR)%.zip: $(PROJECT_DIR)%/*/Program.cs | $(PROJECT_DIR)/%/*/*.cs
543-
@(printf '<Project Sdk="Microsoft.NET.Sdk">\n <PropertyGroup>\n <OutputType>Exe</OutputType>\n <TargetFramework>net10.0</TargetFramework>\n <ImplicitUsings>enable</ImplicitUsings>\n <Nullable>enable</Nullable>\n </PropertyGroup>\n \n</Project>') > $(dir $<)$(notdir $(patsubst %/,%,$(dir $<))).csproj
544-
# We now zip the folder:
543+
@(printf '<Project Sdk="Microsoft.NET.Sdk">\n <PropertyGroup>\n <OutputType>Exe</OutputType>\n <TargetFramework>net8.0</TargetFramework>\n <RollForward>LatestMajor</RollForward>\n \n</PropertyGroup>\n</Project>') > $(dir $<)$(notdir $(patsubst %/,%,$(dir $<))).csproj
544+
# We now zip the folder:
545545
@cd $(dir $(patsubst %/,%,$(dir $<))) && 7z a $(notdir $@) $(notdir $*) -xr\!.vs -xr\!.directory > nul && mv $(notdir $@) ../
546-
# We compress (silently, thanks to the -bso0 -bsp0 options) the folder containing the csproj and the code
547-
# Finally, we clean the files:
546+
# We compress (silently, thanks to the -bso0 -bsp0 options) the folder containing the csproj and the code
547+
# Finally, we clean the files:c
548548
@rm $(dir $<)$(notdir $(patsubst %/,%,$(dir $<))).csproj
549549

550-
# Rule to create one individual project and zip it:
551-
# The code below is taken from and documented at
552-
# https://github.com/princomp/C-Sharp-project-maker
553-
$(PROJECT_DIR)%_v4.5.2.zip: $(PROJECT_DIR)%/*/Program.cs | $(PROJECT_DIR)/%/*/*.cs
554-
#
555-
# The structure of an archive is as follows:
556-
# └───<Solution> $(notdir $*)
557-
# ├── <Solution.sln> $(dir $(patsubst %/,%,$(dir $<)))/$(notdir $*).sln
558-
# └── <Project> $(dir $<)
559-
# ├── <Project>.csproj $(dir $<)$(notdir $(patsubst %/,%,$(dir $<))).csproj
560-
# ├── Properties $(dir $<)Properties
561-
# │   └── AssemblyInfo.cs $(dir $<)Properties/AssemblyInfo.cs
562-
# ├── Program.cs $<
563-
# └── <Class>.cs
564-
# We will also use the following:
565-
# $(notdir $*) # Name of Solution
566-
# $(notdir $(patsubst %/,%,$(dir $<))) # Name of Project
567-
# $@ # Name of target, the zip file
568-
# cat $< | grep -oP '(((internal)|(public)|(private)|(protected)|(sealed)|(abstract)|(static))?[\s\r\n\t]+){0,2}class[\s]+\K([[:alnum:]]|_)*[\s\S]' # name of the class in Program.cs
569-
#
570-
# We start by creating the required Properties directory:
571-
@mkdir -p $(dir $<)Properties
572-
# We create the .sln file,
573-
# The new lines have to be escaped with \n:
574-
@(printf '\nMicrosoft Visual Studio Solution File, Format Version 12.00\n# Visual Studio 14\nVisualStudioVersion = 14.0.25420.1\nMinimumVisualStudioVersion = 10.0.40219.1\nProject("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "$(notdir $(patsubst %/,%,$(dir $<)))", "$(notdir $(patsubst %/,%,$(dir $<)))\\$(notdir $(patsubst %/,%,$(dir $<))).csproj", "{C579075D-4630-47FA-9BE4-0E3E51DDFEA5}"\nEndProject\nGlobal\n GlobalSection(SolutionConfigurationPlatforms) = preSolution\n Debug|Any CPU = Debug|Any CPU\n Release|Any CPU = Release|Any CPU\n EndGlobalSection\n GlobalSection(ProjectConfigurationPlatforms) = postSolution\n {C579075D-4630-47FA-9BE4-0E3E51DDFEA5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU\n {C579075D-4630-47FA-9BE4-0E3E51DDFEA5}.Debug|Any CPU.Build.0 = Debug|Any CPU\n {C579075D-4630-47FA-9BE4-0E3E51DDFEA5}.Release|Any CPU.ActiveCfg = Release|Any CPU\n {C579075D-4630-47FA-9BE4-0E3E51DDFEA5}.Release|Any CPU.Build.0 = Release|Any CPU\n EndGlobalSection\n GlobalSection(SolutionProperties) = preSolution\n HideSolutionNode = FALSE\n EndGlobalSection\nEndGlobal\n') > $(dir $(patsubst %/,%,$(dir $<)))/$(notdir $*).sln
575-
# We create the .csproj file.
576-
# New lines are escaped as \n
577-
# Single quotes are escaped as '\''
578-
# $ are escaped as $$ (if they are *not* to be interpreted, i.e escape $(MSBuildToolsVersion) but not $(notdir $*)
579-
# and \ are escaped as \\
580-
# The additional difficulty is that we want the csproj to include all the .cs files in the <Solution> folder
581-
# (so, not only the Program.cs, but also possible (multiple) <Class>.cs).
582-
# We create the part in five parts:
583-
# 1. The initial set-up,
584-
# 2. We insert the name of the class in Program.cs to be the default startup object,
585-
# 3. We continue with the standard template of the file,
586-
# 4. Then, we append "<Compile Include="<name of the cs file>" />" for each cs file in the <Solution> folder,
587-
# 5. Finally, we append the required closing to the file.
588-
# Apparently, another way would be to use wildcards (cf. https://stackoverflow.com/a/9438419)
589-
@(printf '<?xml version="1.0" encoding="utf-8"?>\n<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\n <Import Project="$$(MSBuildExtensionsPath)\$$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('\''$$(MSBuildExtensionsPath)\$$(MSBuildToolsVersion)\Microsoft.Common.props'\'')" />\n <PropertyGroup>\n\t<StartAction>Project</StartAction>\n\t<ExternalConsole>true</ExternalConsole>\n\t<Configuration Condition=" '\''$$(Configuration)'\'' == '\'''\'' ">Debug</Configuration>\n\t<Platform Condition=" '\''$$(Platform)'\'' == '\'''\'' ">AnyCPU</Platform>\n\t<ProjectGuid>{C579075D-4630-47FA-9BE4-0E3E51DDFEA5}</ProjectGuid>\n\t<OutputType>Exe</OutputType>\n\t<AppDesignerFolder>Properties</AppDesignerFolder>\n\t<RootNamespace>$(notdir $*)</RootNamespace>\n\t<AssemblyName>$(notdir $*)</AssemblyName>\n\t<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>\n\t<FileAlignment>512</FileAlignment>\n\t<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>\n </PropertyGroup>\n <PropertyGroup Condition=" '\''$$(Configuration)|$$(Platform)'\'' == '\''Debug|AnyCPU'\'' ">\n\t<PlatformTarget>AnyCPU</PlatformTarget>\n\t<DebugSymbols>true</DebugSymbols>\n\t<DebugType>full</DebugType>\n\t<Optimize>false</Optimize>\n\t<OutputPath>bin\Debug\</OutputPath>\n\t<DefineConstants>DEBUG;TRACE</DefineConstants>\n\t<ErrorReport>prompt</ErrorReport>\n\t<WarningLevel>4</WarningLevel>\n </PropertyGroup>\n <PropertyGroup Condition=" '\''$$(Configuration)|$$(Platform)'\'' == '\''Release|AnyCPU'\'' ">\n\t<PlatformTarget>AnyCPU</PlatformTarget>\n\t<DebugType>pdbonly</DebugType>\n\t<Optimize>true</Optimize>\n\t<OutputPath>bin\Release\</OutputPath>\n\t<DefineConstants>TRACE</DefineConstants>\n\t<ErrorReport>prompt</ErrorReport>\n\t<WarningLevel>4</WarningLevel>\n </PropertyGroup>\n <PropertyGroup>\n\t<StartupObject>\n\t\t') > $(dir $<)$(notdir $(patsubst %/,%,$(dir $<))).csproj; \
590-
# The following grep the name of the class in Program.cs,
591-
# following the official syntax given at
592-
# https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/language-specification/classes#1521-general
593-
# class_declaration
594-
# : attributes? class_modifier* 'partial'? 'class' identifier
595-
# type_parameter_list? class_base? type_parameter_constraints_clause*
596-
# class_body ';'?
597-
# ;
598-
# Inspired by the regular expression given at
599-
# https://stackoverflow.com/a/19858777
600-
@grep -oP '(((internal)|(public)|(private)|(protected)|(sealed)|(abstract)|(static))?[\s\r\n\t]+){0,2}class[\s]+\K([[:alnum:]]|_)*[\s\S]' $(dir $<)/Program.cs >> $(dir $<)$(notdir $(patsubst %/,%,$(dir $<))).csproj \
601-
&& (printf '\t</StartupObject>\n </PropertyGroup>\n\t<ItemGroup>\n\t<Reference Include="System" />\n\t<Reference Include="System.Core" />\n\t<Reference Include="System.Xml.Linq" />\n\t<Reference Include="System.Data.DataSetExtensions" />\n\t<Reference Include="Microsoft.CSharp" />\n\t<Reference Include="System.Data" />\n\t<Reference Include="System.Net.Http" />\n\t<Reference Include="System.Xml" />\n </ItemGroup>\n <ItemGroup>\n') >> $(dir $<)$(notdir $(patsubst %/,%,$(dir $<))).csproj \
602-
&& for fileA in $(dir $<)*.cs; do \
603-
printf '\t<Compile Include="'$$(basename $${fileA})'" />\n' >> $(dir $<)$(notdir $(patsubst %/,%,$(dir $<))).csproj ; \
604-
done; \
605-
(printf '\t<Compile Include="Properties\AssemblyInfo.cs" />\n </ItemGroup>\n <Import Project="$$(MSBuildToolsPath)\Microsoft.CSharp.targets" />\n</Project>\n') >> $(dir $<)$(notdir $(patsubst %/,%,$(dir $<))).csproj \
606-
# We create the Properties\AssemblyInfo.cs file.
607-
@touch $(dir $<)Properties/AssemblyInfo.cs
608-
# Finally, we can zip the folder:
609-
@cd $(dir $(patsubst %/,%,$(dir $<)))../ && 7z a $(notdir $@) $(notdir $*) -xr\!.vs -xr\!.directory > nul
610-
# We compress the folder containing the sln and the folder containing the csproj and the code
611-
# But we exclude the .vs folder and .directory file
612-
# Finally, we clean the files:
613-
@rm -rf $(dir $(patsubst %/,%,$(dir $<)))/$(notdir $*).sln
614-
@rm -rf $(dir $<)$(notdir $(patsubst %/,%,$(dir $<))).csproj
615-
@rm -rf $(dir $<)Properties
616-
@rm -rf $(dir $<)Properties/AssemblyInfo.cs
617-
618550
# -------------------------------
619551
# Book files
620552
# -------------------------------

0 commit comments

Comments
 (0)