Open graysuit opened 1 year ago
specify --target:WinExe
if you are compiling a winform program.
This will sign bflat the compiler to add supporting libs, instead of adding yourself.
I'm not sure where I provide it ?
C:\Users\gray\Desktop\bflata-main>bflata.exe build C:\Users\gray\Desktop\BigThumbs\BigThumbs.csproj --target:WinExe
BFlatA V1.5.0.2 @github.com/xiaoyuvax/bflata
Description:
A wrapper/build script generator for BFlat, a native C# compiler, for recusively building .csproj file with:
- Referenced projects
- Nuget package dependencies
- Embedded resources
Before using BFlatA, you should get BFlat first at https://flattened.net.
--ARGS--------------------------------
Action :Build
BuildMode :Flat
DepositDep :Off
Target :WinExe
TargetOS :windows
Output :<Default>
TargetFx :net7.0
PackageRoot :<N/A>
Home :C:\Users\gray\Desktop\bflata-main
Args for BFlat :
--LIB EXCLU---------------------------
--LIB CACHE---------------------------
--PARSING-----------------------------
Parsing Project:C:\Users\gray\Desktop\BigThumbs\BigThumbs.csproj ...
CompileInclude [Include] 729 items added!
Content [Include] 1 items added!
EmbeddedResource [Include] 9 items added!
--SCRIPTING---------------------------
Read in 3 resources from "C:\Users\gray\Desktop\BigThumbs\Form1.resx"
Writing resource file... Done.
Read in 24 resources from "C:\Users\gray\Desktop\BigThumbs\Properties\Resources.resx"
Writing resource file... Done.
Read in 1 resources from "C:\Users\gray\Desktop\BigThumbs\Renamer.resx"
Writing resource file... Done.
Generating build script for:BigThumbs
- Found 1 args to be passed to BFlat.
- Found 28 code files(*.cs)
- Found 3 embedded resources(*.resx and other)
Script:build.rsp written!
--BUILDING----------------------------
Building in FLAT mode:BigThumbs...
- Executing build script: bflat build @build.rsp...
C:\Users\gray\Desktop\BigThumbs\Classes\Cacher.cs(15,22): error CS0234: The type or namespace name 'Forms' does not exist in the namespace 'System.Windows' (are you missing an assembly reference?)
C:\Users\gray\Desktop\BigThumbs\Classes\Cacher.cs(17,22): error CS0234: The type or namespace name 'Media' does not exist in the namespace 'System.Windows' (are you missing an assembly reference?)
C:\Users\gray\Desktop\BigThumbs\Classes\helper.cs(1,7): error CS0246: The type or namespace name 'Shell32' could not be found (are you missing a using directive or an assembly reference?)
...
i think you should also serve the --pr:<packageroot>
option,so that Bflata can search for package references.
but have to say in the first place that compiling winform program is still problematic for bflat, and even with NativeAOT.
and still, you should use --resgen:
option to turn on two --feature:
args, rather than modfiying the default path to resgen.exe in the code.
and also you'd better direct the -h:
option to the home of your solution, instead of the executing path.
packageroot ? If I understand, its for nuget packages, right ? But I don't have any. Just an .net dll and an native dll.
Also its thinking my net is 7.0:
TargetFx :net7.0
But my dotnet installed at C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App\5.0.17
Yes, you may ignore -pr if no nuget packages referenced. but seems that Shell32 is something referenced. What is it?
According to my experience, bflat will add references to the shared framework Microsoft.WindowsDesktop.App of its own(net7) if you specified --target:winexe
, and such error as "The type or namespace name 'Forms' does not exist in the namespace 'System.Windows' ..." would be eliminated. but seems not the case according to ur output.
Shell32 is present at C:\Windows\System32\shell32.dll
Yes --target:winexe
didn't help. It still need references.
But atleast its still great to automatically parse csproj files and put in one.
So are there any manual way of referencing ?
`"C:\Users\gray\Desktop\BigThumbs\Classes\helper.cs(1,7): error CS0246: The type or namespace name 'Shell32' could not be found (are you missing a using directive or an assembly reference?)" this line seems weird.
if you are referenceing Shell32.dll with DLLImport
, it should not appear in the compilation process, cos it's a Dynamic Link Library, which should not participate in the compilation. i.e. the compiler would not take on it. Otherwise, i wonder if you reference Shell32.dll as a COM object library?
Can you show me the .cspoj file where you reference Shell32.dll?
Yes its com reference. Here's my csproj file:
<?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>{AE57F620-65B7-4388-9F48-3B322937681D}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>BigThumbs</RootNamespace>
<AssemblyName>BigThumbs</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
<TargetFrameworkProfile />
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x64\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>false</Prefer32Bit>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>bin\x64\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>false</Prefer32Bit>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup>
<StartupObject>BigThumbs.Program</StartupObject>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x86\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<OutputPath>bin\x86\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>icon.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
<Reference Include="Cyotek.Windows.Forms.ImageBox">
<HintPath>lib\Cyotek.Windows.Forms.ImageBox.dll</HintPath>
</Reference>
<Reference Include="Microsoft.VisualBasic" />
<Reference Include="Microsoft.VisualBasic.Compatibility" />
<Reference Include="Microsoft.VisualBasic.Compatibility.Data" />
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Data" />
<Reference Include="System.Numerics" />
<Reference Include="System.Xml.Linq" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
<Reference Include="WindowsBase" />
</ItemGroup>
<ItemGroup>
<COMReference Include="Shell32">
<WrapperTool>tlbimp</WrapperTool>
<VersionMinor>0</VersionMinor>
<VersionMajor>1</VersionMajor>
<Guid>50a7e9b0-70ef-11d1-b75a-00a0c90564fe</Guid>
<Lcid>0</Lcid>
<Isolated>false</Isolated>
<EmbedInteropTypes>true</EmbedInteropTypes>
</COMReference>
</ItemGroup>
<ItemGroup>
<Compile Include="Classes\Cacher.cs" />
<Compile Include="Classes\helper.cs" />
<Compile Include="Classes\MsgBox.cs" />
<Compile Include="Classes\Natural_Sort.cs" />
<Compile Include="Classes\RecycleBin.cs" />
<Compile Include="Classes\ZipStorer.cs" />
<Compile Include="Controls\DataGrid.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Controls\DataGridViewProgressColumn.cs" />
<Compile Include="Controls\SplitPanel.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Form1.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Form1.Designer.cs">
<DependentUpon>Form1.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Classes\SettingsSaver.cs" />
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="Renamer.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Renamer.Designer.cs">
<DependentUpon>Renamer.cs</DependentUpon>
</Compile>
<Compile Include="ShellStuff\ComReleaser.cs" />
<Compile Include="ShellStuff\CopyEngineResult.cs" />
<Compile Include="ShellStuff\FileOperation.cs" />
<Compile Include="ShellStuff\FileOperationFlags.cs" />
<Compile Include="ShellStuff\FileOperationProgressSink.cs" />
<Compile Include="ShellStuff\Interfaces\IFileOperation.cs" />
<Compile Include="ShellStuff\Interfaces\IFileOperationProgressSink.cs" />
<Compile Include="ShellStuff\Interfaces\IShellItem.cs" />
<Compile Include="ShellStuff\ShellCommon.cs" />
<EmbeddedResource Include="Form1.resx">
<DependentUpon>Form1.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>PublicResXFileCodeGenerator</Generator>
<SubType>Designer</SubType>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<EmbeddedResource Include="Renamer.resx">
<DependentUpon>Renamer.cs</DependentUpon>
</EmbeddedResource>
<None Include="app.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</ItemGroup>
<ItemGroup>
<None Include="assets\folder\folderDisabled_hasimages.png" />
</ItemGroup>
<ItemGroup>
<None Include="assets\folder\folder.png" />
</ItemGroup>
<ItemGroup>
<None Include="assets\folder\folder_hasimages.png" />
</ItemGroup>
<ItemGroup>
<None Include="assets\folder\folderDisabled.png" />
</ItemGroup>
<ItemGroup>
<None Include="assets\up.png" />
</ItemGroup>
<ItemGroup>
<None Include="assets\drive.png" />
</ItemGroup>
<ItemGroup>
<None Include="assets\shortcuts\desktop.png" />
</ItemGroup>
<ItemGroup>
<None Include="assets\shortcuts\documents.png" />
</ItemGroup>
<ItemGroup>
<None Include="assets\shortcuts\downloads.png" />
</ItemGroup>
<ItemGroup>
<None Include="assets\shortcuts\images.png" />
</ItemGroup>
<ItemGroup>
<None Include="assets\shortcuts\music.png" />
</ItemGroup>
<ItemGroup>
<None Include="assets\shortcuts\video.png" />
</ItemGroup>
<ItemGroup>
<None Include="assets\shortcuts\home.png" />
</ItemGroup>
<ItemGroup>
<None Include="assets\shortcuts\180.jpg" />
</ItemGroup>
<ItemGroup>
<None Include="assets\shortcuts\CW90.jpg" />
</ItemGroup>
<ItemGroup>
<None Include="assets\shortcuts\CWW90.jpg" />
</ItemGroup>
<ItemGroup>
<None Include="assets\shortcuts\fullimage.png" />
</ItemGroup>
<ItemGroup>
<None Include="assets\shortcuts\forward.png" />
</ItemGroup>
<ItemGroup>
<None Include="assets\shortcuts\forward_disabled.png" />
</ItemGroup>
<ItemGroup>
<None Include="assets\shortcuts\back.png" />
</ItemGroup>
<ItemGroup>
<None Include="assets\shortcuts\back_disabled.png" />
</ItemGroup>
<ItemGroup>
<None Include="assets\shortcuts\goParent_disabled.png" />
</ItemGroup>
<ItemGroup>
<None Include="assets\shortcuts\goParent.png" />
</ItemGroup>
<ItemGroup>
<COMReference Include="Shell32">
<Guid>{50A7E9B0-70EF-11D1-B75A-00A0C90564FE}</Guid>
<VersionMajor>1</VersionMajor>
<VersionMinor>0</VersionMinor>
<Lcid>0</Lcid>
<WrapperTool>tlbimp</WrapperTool>
<Isolated>False</Isolated>
<EmbedInteropTypes>True</EmbedInteropTypes>
</COMReference>
</ItemGroup>
<ItemGroup>
<None Include="assets\hundred.png" />
<None Include="assets\folder\Selected.png" />
<None Include="assets\folder\Has_Images.png" />
<None Include="assets\folder\Normal.png" />
<None Include="assets\shortcuts\font.png" />
<None Include="assets\folder\Has_Folders.png" />
<None Include="assets\drive_selected.png" />
<None Include="assets\PanAllSymbol.png" />
<None Include="assets\ImageBox.bmp" />
<None Include="assets\PanAll.cur" />
<Content Include="icon.ico" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
<COMReference Include="Shell32">
here it is, COM dll makes it complicated, and BFlatA now doesn't process this type of reference so far cos no path is directly given in the .csporj to the .dll file, and i also don't know if -r
option works with bflat. You may add the path to shell32.dll with -r option in the generated build.rsp file manually, and check if bflat could compile with it (i.e. you won't see any error related to shell32.dll) .
Please pardon me if it looks too noob
build.rsp supposed to work with bflataA ?
C:\Users\gray\Desktop\bflata-main>bflata build.rsp
BFlatA V1.5.0.2 @github.com/xiaoyuvax/bflata
Description:
A wrapper/build script generator for BFlat, a native C# compiler, for recusively building .csproj file with:
- Referenced projects
- Nuget package dependencies
- Embedded resources
Before using BFlatA, you should get BFlat first at https://flattened.net.
--ARGS--------------------------------
Action :Script
BuildMode :None
DepositDep :Off
Target :Exe
TargetOS :windows
Output :<Default>
TargetFx :net7.0
PackageRoot :<N/A>
Home :C:\Users\gray\Desktop\bflata-main
Args for BFlat :
--LIB EXCLU---------------------------
--LIB CACHE---------------------------
--PARSING-----------------------------
Unhandled Exception: System.ArgumentException: The path is empty. (Parameter 'path')
at System.IO.Path.GetFullPath(String) + 0x91
at BFlatA.BFlatA.ParseProject(BuildMode, String, String[], String, String, String&, String&, String&, List`1&, List`1&, List`1&, List`1&, List`1&, List`1&, List`1&, Dictionary`2&, Boolean) + 0xca
at BFlatA.BFlatA.Main(String[]) + 0xf70
at bflata!<BaseAddress>+0x422766
or should I manually supply to bflat ?
Not with BFlatA the wrapper,but with BFlat, the compiler.
usage:
bflat build @build.rsp
C:\Users\gray\Desktop\bflata-main>bflat build @build.rsp
error CS0009: Metadata file 'C:\Windows\System32\shell32.dll' could not be opened -- PE image doesn't contain managed metadata.
C:\Users\gray\Desktop\BigThumbs\Classes\Cacher.cs(15,22): error CS0234: The type or namespace name 'Forms' does not exist in the namespace 'System.Windows' (are you missing an assembly reference?)
C:\Users\gray\Desktop\BigThumbs\Classes\Cacher.cs(17,22): error CS0234: The type or namespace name 'Media' does not exist in the namespace 'System.Windows' (are you missing an assembly reference?)
C:\Users\gray\Desktop\BigThumbs\Classes\helper.cs(1,7): error CS0246: The type or namespace name 'Shell32' could not be found (are you missing a using directive or an assembly reference?)
C:\Users\gray\Desktop\BigThumbs\Classes\helper.cs(7,22): error CS0234: The type or namespace name 'Forms' does not exist in the namespace 'System.Windows' (are you missing an assembly reference?)
C:\Users\gray\Desktop\BigThumbs\Classes\MsgBox.cs(3,22): error CS0234: The type or namespace name 'Forms' does not exist in the namespace 'System.Windows' (are you missing an assembly reference?)
...
Here's build.rsp
#Project:[BigThumbs], Timestamp:[4/5/2023 4:00:49 PM]
#This response file is generated by BFlatA(https://github.com/xiaoyuvax/bflata), and is intended to be compiled by BFlat (https://github.com/bflattened/bflat).
-o BigThumbs.exe
--target WinExe
--ldflags /INCREMENTAL:no
C:\Users\gray\Desktop\BigThumbs\Classes\Cacher.cs
C:\Users\gray\Desktop\BigThumbs\Classes\helper.cs
C:\Users\gray\Desktop\BigThumbs\Classes\MsgBox.cs
C:\Users\gray\Desktop\BigThumbs\Classes\Natural_Sort.cs
C:\Users\gray\Desktop\BigThumbs\Classes\RecycleBin.cs
C:\Users\gray\Desktop\BigThumbs\Classes\SettingsSaver.cs
C:\Users\gray\Desktop\BigThumbs\Classes\ZipStorer.cs
C:\Users\gray\Desktop\BigThumbs\Controls\DataGrid.cs
C:\Users\gray\Desktop\BigThumbs\Controls\DataGridViewProgressColumn.cs
C:\Users\gray\Desktop\BigThumbs\Controls\SplitPanel.cs
C:\Users\gray\Desktop\BigThumbs\Form1.cs
C:\Users\gray\Desktop\BigThumbs\Form1.Designer.cs
C:\Users\gray\Desktop\BigThumbs\Program.cs
C:\Users\gray\Desktop\BigThumbs\Properties\AssemblyInfo.cs
C:\Users\gray\Desktop\BigThumbs\Properties\Resources.Designer.cs
C:\Users\gray\Desktop\BigThumbs\Properties\Settings.Designer.cs
C:\Users\gray\Desktop\BigThumbs\Renamer.cs
C:\Users\gray\Desktop\BigThumbs\Renamer.Designer.cs
C:\Users\gray\Desktop\BigThumbs\ShellStuff\ComReleaser.cs
C:\Users\gray\Desktop\BigThumbs\ShellStuff\CopyEngineResult.cs
C:\Users\gray\Desktop\BigThumbs\ShellStuff\FileOperation.cs
C:\Users\gray\Desktop\BigThumbs\ShellStuff\FileOperationFlags.cs
C:\Users\gray\Desktop\BigThumbs\ShellStuff\FileOperationProgressSink.cs
C:\Users\gray\Desktop\BigThumbs\ShellStuff\Interfaces\IFileOperation.cs
C:\Users\gray\Desktop\BigThumbs\ShellStuff\Interfaces\IFileOperationProgressSink.cs
C:\Users\gray\Desktop\BigThumbs\ShellStuff\Interfaces\IShellItem.cs
C:\Users\gray\Desktop\BigThumbs\ShellStuff\ShellCommon.cs
C:\Users\gray\Desktop\BigThumbs\Thumbs\Thumb.cs
-res C:\Users\gray\AppData\Local\Temp\3qbcjn0s.zws\BigThumbs.Renamer.resources
-res C:\Users\gray\AppData\Local\Temp\em3o0ib1.tfh\BigThumbs.Form1.resources
-res C:\Users\gray\AppData\Local\Temp\jvh44wic.t1z\BigThumbs.Properties.Resources.resources
-r C:\Windows\System32\shell32.dll
seems bflat, the compiler doesn't support reference to COM dll. like Shell32.dll.
I just tried to build a winform project of my own successfully and found that -pr:
option is needed, so that dependencies of
Microsoft.WindowsDesktop.App can be added. therefore you must have dotnet7 installed firstly.
and seems the WinExe is only related if you don't want your WinForm program launched out of a console window.
and there is a small bug in parsing the Microsoft.WindowsDesktop.App path, i've updated the code just now.
First try:
How do I add references ? For bflat we set
-r
. whats best advice on that ?