Project\Properties\PublishProfiles\FolderProfile.pubxml

 

<?xml version="1.0" encoding="utf-8"?>

<!--

https://go.microsoft.com/fwlink/?LinkID=208121.

-->

<Project>

  <PropertyGroup>

    <Configuration>Release</Configuration>

    <Platform>Any CPU</Platform>

    <PublishDir>\\yourpath</PublishDir>

    <PublishProtocol>FileSystem</PublishProtocol>

    <_TargetId>Folder</_TargetId>

<RuntimeIdentifier>win-x64</RuntimeIdentifier>

    <TargetFramework>net8.0-windows10.0.22621.0</TargetFramework>

    <SelfContained>true</SelfContained>

<PublishSingleFile>True</PublishSingleFile>

  </PropertyGroup>

</Project>

 

---------------------

Essential

RuntimeIdentifier

SelfContained        ----- true is framework include

PublishSingleFile

 

Prerequirement (how to set unpackaged proejct)

https://jhchoi.tistory.com/23

 

Method 1

(menu)build - publish

 

Method 2

(Soultion Explorer)project : right click - publish

 

Method 3 (.NET CLI / Example)

dotnet publish -c Release -r win10-your_version --self-contained false /p:PublishSingleFile=true /p:PublishProfile=win10-your_version

 

Build Option

project_folder\Properties\PublishProfiles\win10-your_version.pubxml

 

<PublishDir>bin\\YOUR_FOLDER</PublishDir>

<SelfContained>false</SelfContained>                   <!--true includes framework, false does not.-->

<PublishSingleFile>true</PublishSingleFile>    <!--Essential for single exe creation.-->

<PublishReadyToRun Condition="'$(Configuration)' == 'Debug'">False</PublishReadyToRun>

<PublishReadyToRun Condition="'$(Configuration)' != 'Debug'">true</PublishReadyToRun>

<Configuration>Release</Configuration>

<TargetFramework>net8.0-windows10.0.22621.0</TargetFramework> <!--Your windows version-->

 

Comment

Without framework, it's around 60MB.

with framework, it jumps to about 120MB.

However, WPF or WinForms are around 150KB.
 
 

 

'c# > winui3' 카테고리의 다른 글

winui 3 net8 unpackaged 프로젝트 환경 설정 하기  (4) 2024.01.04

요약

.csproj  의 PropertyGroup를 아래와 같이 수정, 추가 해준다.

그 후 project\Properties\PublishProfiles\ 경로의 각 pubxml파일에도 RuntimeIdentifiers를 수정해준다.

마지막으로 nuget package를 winui 최신 sdk버전으로 업데이트 해준다.

 

수정 필요 코드

 <TargetFramework>net8.0-windows10.0.22621.0</TargetFramework>

 <RuntimeIdentifiers>win-x86;win-x64;win-arm64</RuntimeIdentifiers>

 

추가 필요 코드 // packaged 로 msix로 만드려면 이 두개를 추가하지 않는다.

 <WindowsPackageType>None</WindowsPackageType>

<WindowsAppSDKSelfContained>true</WindowsAppSDKSelfContained>

 

csproj PropertyGroup 부분 종합

  <PropertyGroup>

    <OutputType>WinExe</OutputType>

    <TargetFramework>net8.0-windows10.0.22621.0</TargetFramework>

    <TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>

    <RootNamespace>App10</RootNamespace>

    <ApplicationManifest>app.manifest</ApplicationManifest>

    <Platforms>x86;x64;ARM64</Platforms>

    <RuntimeIdentifiers>win-x86;win-x64;win-arm64</RuntimeIdentifiers>

    <PublishProfile>win10-$(Platform).pubxml</PublishProfile>

    <UseWinUI>true</UseWinUI>

    <EnableMsixTooling>true</EnableMsixTooling>

    <WindowsPackageType>None</WindowsPackageType>

<WindowsAppSDKSelfContained>true</WindowsAppSDKSelfContained>

  </PropertyGroup>

 

===

ERROR CASE1

XamlCheckProcessRequirements(); 부분에서 아래 에러가 발생한 경우

System.DllNotFoundException: 'Unable to load DLL 'Microsoft.ui.xaml.dll' or one of its dependencies: 지정된 모듈을 찾을 수 없습니다. (0x8007007E)'

 

아래 구문이 추가되어있지 않은 경우

<WindowsPackageType>None</WindowsPackageType>

 

===

ERROR CASE2

예외 발생: 'System.DllNotFoundException'(Microsoft.WindowsAppRuntime.Bootstrap.Net.dll)

 

아래 이 구문이 추가가 되어있지 않거나, windows app sdk 가 알맞은 버전이 설치되어있지 않은 경우.

<WindowsAppSDKSelfContained>true</WindowsAppSDKSelfContained>

===

ERROR CASE3

디버깅하려면 먼저 프로젝트를 배포해야 합니다. Configuration Manager 배포를 사용하도록 설정하세요.

 

위 오류가 출력될 경우 바로 아래 구문을 주석처리 해보자.

<!--<WindowsPackageType>None</WindowsPackageType>-->

 

 

DEP1560: 매니페스트 파일 "C:\Users\choejaeho\source\repos\App10\App10\bin\ARM64\Release\net8.0-windows10.0.22621.0\win-arm64\AppxManifest.xml"을(를) 읽지 못했습니다. 이 파일을 다시 생성해야 할 수 있습니다. 오류를 수정하려면 솔루션 다시 빌드 명령을 실행하세요. FileNotFoundException - 'C:\Users\choejaeho\source\repos\App10\App10\bin\ARM64\Release\net8.0-windows10.0.22621.0\win-arm64\AppxManifest.xml' 파일을 찾을 수 없습니다. [0x80070002] - C:\Users\choejaeho\source\repos\App10\App10\bin\ARM64\Release\net8.0-windows10.0.22621.0\win-arm64\AppxManifest.xml

 

DEP1700: 조리법 파일 "C:\Users\choejaeho\source\repos\App10\App10\bin\x86\Release\net8.0-windows10.0.22621.0\win-x86\App10.build.appxrecipe"이(가) 없습니다. 프로젝트를 빌드해야 할 수도 있습니다.

 

이 DEP 오류 들의 경우에도 위 패키지 타입을 주석처리하거나 본인의 빌드 환경에 알맞은 x86 x64 arm 을 선택하여 빌드한다.

'c# > winui3' 카테고리의 다른 글

winui 3 create single exe  (2) 2024.01.08

MauiProgrma.cs 에 아래(#if winodws 부터)를 추가한다.

FullScreen 은 창이 화면을 꽉 채우게 되어 최소화 최대화 버튼이 보이지 않는 상태이고

Maximize 는 전체 화면으로 최소화 최대화 버튼 등이 보인다.

            var builder = MauiApp.CreateBuilder();
            builder
                .UseMauiApp<App>()
                .ConfigureFonts(fonts =>
                {
                    fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
                    fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
                });
#if WINDOWS
        builder.ConfigureLifecycleEvents(events =>  
        {  
            events.AddWindows(wndLifeCycleBuilder =>  
            {  
                wndLifeCycleBuilder.OnWindowCreated(window =>  
                {  
                    window.ExtendsContentIntoTitleBar = false;  
                    IntPtr hWnd = WinRT.Interop.WindowNative.GetWindowHandle(window);
                    Microsoft.UI.WindowId myWndId = Microsoft.UI.Win32Interop.GetWindowIdFromWindow(hWnd);  
                    var _appWindow = Microsoft.UI.Windowing.AppWindow.GetFromWindowId(myWndId);  
                    //_appWindow.SetPresenter(Microsoft.UI.Windowing.AppWindowPresenterKind.FullScreen);   
                 //if you want to full screen, you can use this line
                   (_appWindow.Presenter as Microsoft.UI.Windowing.OverlappedPresenter).Maximize();   
                //if you want to Maximize the window, you can use this line                    
                });  
            });  
        });
#endif

 

혹은 

MainPage.cs 에서 동일한 내용을 

OnHandlerChanged() 에 추가해서도 사용 가능하다.

protected override void OnHandlerChanged()
      {
            base.OnHandlerChanged();
#if WINDOWS
                  var window = App.Current.Windows.FirstOrDefault().Handler.PlatformView as Microsoft.UI.Xaml.Window;
                  IntPtr windowHandle = WinRT.Interop.WindowNative.GetWindowHandle(window);
                  Microsoft.UI.WindowId windowId = Microsoft.UI.Win32Interop.GetWindowIdFromWindow(windowHandle);
                  Microsoft.UI.Windowing.AppWindow appWindow = Microsoft.UI.Windowing.AppWindow.GetFromWindowId(windowId);
                appWindow.SetPresenter(Microsoft.UI.Windowing.AppWindowPresenterKind.FullScreen);
            //   (appWindow.Presenter as Microsoft.UI.Windowing.OverlappedPresenter).Maximize();
            // this line can maximize the window
#endif
      }

'c# > MAUI' 카테고리의 다른 글

Maui windows admin 권한 얻기  (0) 2022.08.14

1.윈도우 서버 설치

 

2.윈도우 서버 서버관리자에서 DNS, IIS (관리도구 포함) 기능 추가로 설치

 

3.윈도우 서버에 web deploy 설치 

https://www.iis.net/downloads/microsoft/web-deploy

 

4.윈도우 서버 IIS 서버에서 관리서비스 - 원격연결 사용

(서버관리자 기능 추가로 iis 관리도구가 설치 완료 되어야함.)

 

5.윈도우 서버 IIS 사이트 추가하고 배포 설정하기

(사이트 오른쪽 클릭 - 배포 - 배포설정 후 닫기)

 

6.윈도우 서버에 dot net runtime 설치

https://www.microsoft.com/net/download/all

 

7.visual studio 에서 블레이저 서버 프로젝트 생성

 

8.visual studio 에서 프로젝트 오른쪽 클릭후 게시 (솔루션 선택 아님)

 

9.IIS 선택 후 게시 완료

(웹 배포 안될 시 패키지로 배포 선택하여 zip파일 내보내기 후 윈도우 서버로 옮기어 사이트 - 배포 - 패키지 가져오기 한다.)

1,2번의 과정으로 관리자 권한을 얻을 수 있다.

 

1.

app.manifest 파일에 

<requestedExecutionLevel level="requireAdministrator" uiAccess="false"/>

구문 추가

 

<?xml version="1.0" encoding="utf-8"?>

<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">

  <assemblyIdentity version="1.0.0.0" name="MauiApp3.WinUI.app"/>

<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">

<security>

<requestedPrivileges>

<requestedExecutionLevel level="requireAdministrator" uiAccess="false"/>

</requestedPrivileges>

</security>

</trustInfo>

  <application xmlns="urn:schemas-microsoft-com:asm.v3">

    <windowsSettings>

      <!-- The combination of below two tags have the following effect:

           1) Per-Monitor for >= Windows 10 Anniversary Update

           2) System < Windows 10 Anniversary Update

      -->

      <dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true/PM</dpiAware>

      <dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2, PerMonitor</dpiAwareness>

    </windowsSettings>

  </application>

</assembly>

 

 

---

2.

Package.appxmanifest 파일에

  <rescap:Capability Name="allowElevation" />

구문 추가

 

<?xml version="1.0" encoding="utf-8"?>

<Package

  xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"

  xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"

  xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"

  IgnorableNamespaces="uap rescap">

 

  <Identity Name="maui-package-name-placeholder" Publisher="CN=User Name" Version="0.0.0.0" />

 

  <Properties>

    <DisplayName>$placeholder$</DisplayName>

    <PublisherDisplayName>User Name</PublisherDisplayName>

    <Logo>$placeholder$.png</Logo>

  </Properties>

 

  <Dependencies>

    <TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.17763.0" MaxVersionTested="10.0.19041.0" />

    <TargetDeviceFamily Name="Windows.Desktop" MinVersion="10.0.17763.0" MaxVersionTested="10.0.19041.0" />

  </Dependencies>

 

  <Resources>

    <Resource Language="x-generate" />

  </Resources>

 

  <Applications>

    <Application Id="App" Executable="$targetnametoken$.exe" EntryPoint="$targetentrypoint$">

      <uap:VisualElements

        DisplayName="$placeholder$"

        Description="$placeholder$"

        Square150x150Logo="$placeholder$.png"

        Square44x44Logo="$placeholder$.png"

        BackgroundColor="transparent">

        <uap:DefaultTile Square71x71Logo="$placeholder$.png" Wide310x150Logo="$placeholder$.png" Square310x310Logo="$placeholder$.png" />

        <uap:SplashScreen Image="$placeholder$.png" />

      </uap:VisualElements>

    </Application>

  </Applications>

 

  <Capabilities>

  <rescap:Capability Name="runFullTrust" />

  <rescap:Capability Name="allowElevation" />

  </Capabilities>

 

</Package>

'c# > MAUI' 카테고리의 다른 글

[MAUI] windows에서 실행시 전체화면 처리하기  (0) 2023.06.27

c# sql 연결하는 법

 

nuget 패키지 로 system.data.sqlclient 를 설치하여 프로젝트에 참조시킨다.

 

using system.data.sqlclient 

 

            string strConn = "Data Source=IP,port;Initial Catalog=DataBase;User ID=id;Password=pw";
            SqlConnection sqlConn = new SqlConnection(strConn);
            sqlConn.Open();
            SqlCommand myCommand = new SqlCommand();
            myCommand.Connection = sqlConn;
            myCommand.CommandText = "query";
            myCommand.ExecuteNonQuery();
            sqlConn.Close();
cs

+ Recent posts