【发布时间】:2023-06-22 03:34:02
【问题描述】:
单人游戏新手。对于简单的东西,构建时间似乎真的很慢。例如,这个带有几个精灵和一个声音文件的非常小的窗口需要 9 秒。当我调整、构建、调整、构建时,这会加起来。
有没有办法加快构建时间,或者让它们增量?或者也许有不同的方法?
dotnet build
Microsoft (R) Build Engine version 17.0.0-preview-21378-03+d592862ed for .NET
Copyright (C) Microsoft Corporation. All rights reserved.
Determining projects to restore...
All projects are up-to-date for restore.
You are using a preview version of .NET. See: https://aka.ms/dotnet-core-preview
D:/.../snd_music.wma
D:/.../spr_background.jpg
D:/.../spr_lives.png
testGame -> D:\...\Debug\netcoreapp3.1\testGame.dll
Build succeeded.
0 Warning(s)
0 Error(s)
Time Elapsed 00:00:08.45
Target Performance Summary:
1 ms _GenerateRestoreProjectPathWalk 1 calls
1 ms GetAssemblyVersion 1 calls
1 ms _CheckForCompileOutputs 1 calls
1 ms CollectPackageDownloads 1 calls
1 ms _GenerateRestoreProjectSpec 1 calls
1 ms GenerateTargetFrameworkMonikerAttribute 1 calls
1 ms _GetCopyToOutputDirectoryItemsFromTransitiveProjectReferences 1 calls
1 ms _GetProjectReferenceTargetFrameworkProperties 1 calls
1 ms _CheckForInvalidConfigurationAndPlatform 1 calls
1 ms _GenerateRestoreProjectPathItemsPerFramework 1 calls
1 ms _CheckForUnsupportedAppHostUsage 1 calls
1 ms _CheckForNETCoreSdkIsPreview 1 calls
1 ms ResolveLockFileReferences 1 calls
1 ms _GenerateDotnetCliToolReferenceSpecs 1 calls
1 ms AddWindowsSdkKnownFrameworkReferences 2 calls
2 ms CheckForDuplicateItems 1 calls
2 ms _ComputeUserRuntimeAssemblies 1 calls
2 ms _CollectTargetFrameworkForTelemetry 2 calls
2 ms GenerateNETCompatibleDefineConstants 1 calls
2 ms _GenerateCompileDependencyCache 1 calls
2 ms _GetCopyToOutputDirectoryItemsFromThisProject 1 calls
2 ms CreateManifestResourceNames 1 calls
2 ms AssignTargetPaths 1 calls
2 ms IncrementalClean 1 calls
2 ms ApplyImplicitVersions 2 calls
2 ms _GetRestoreTargetFrameworksOutput 1 calls
2 ms CoreGenerateAssemblyInfo 1 calls
2 ms _ComputeReferenceAssemblies 1 calls
3 ms CheckForImplicitPackageReferenceOverrides 2 calls
3 ms CreateGeneratedAssemblyInfoInputsCacheFile 1 calls
3 ms ResolveFrameworkReferences 1 calls
4 ms SplitResourcesByCulture 1 calls
4 ms PrepareForBuild 1 calls
4 ms _GenerateProjectRestoreGraphPerFramework 1 calls
4 ms IncludeContent 4 calls
6 ms _HandlePackageFileConflicts 1 calls
6 ms GenerateMSBuildEditorConfigFileCore 1 calls
6 ms _GetRestoreProjectStyle 2 calls
7 ms PrepareContentBuilder 1 calls
7 ms ResolveTargetingPackAssets 1 calls
8 ms _CleanGetCurrentAndPriorFileWrites 1 calls
9 ms _GetAllRestoreProjectPathItems 1 calls
9 ms UpdateAspNetToFrameworkReference 2 calls
13 ms _GenerateRuntimeConfigurationFilesInputCache 1 calls
15 ms _LoadRestoreGraphEntryPoints 1 calls
15 ms GetCopyToOutputDirectoryItems 1 calls
16 ms _CopyFilesMarkedCopyLocal 1 calls
18 ms CollectContentReferences 1 calls
24 ms FindReferenceAssembliesForReferences 1 calls
31 ms CopyFilesToOutputDirectory 1 calls
40 ms _GetRestoreSettings 1 calls
84 ms ResolveProjectReferences 1 calls
88 ms ResolvePackageAssets 1 calls
103 ms GenerateBuildDependencyFile 1 calls
109 ms GenerateBuildRuntimeConfigurationFiles 1 calls
129 ms _CopyOutOfDateSourceItemsToOutputDirectory 1 calls
158 ms ProcessFrameworkReferences 2 calls
158 ms _FilterRestoreGraphProjectInputItems 1 calls
170 ms ResolveAssemblyReferences 1 calls
171 ms _CreateAppHost 1 calls
193 ms CoreCompile 1 calls
231 ms _GenerateRestoreGraph 1 calls
335 ms Restore 1 calls
7016 ms RunContentBuilder 1 calls
Task Performance Summary:
0 ms ValidateExecutableReferences 1 calls
0 ms GetAssemblyVersion 1 calls
0 ms FindAppConfigFile 1 calls
1 ms ResolveFrameworkReferences 1 calls
1 ms GetRestoreFrameworkReferencesTask 1 calls
1 ms Delete 1 calls
1 ms GetRestoreProjectReferencesTask 1 calls
1 ms Message 6 calls
1 ms CheckForDuplicateFrameworkReferences 2 calls
1 ms GetRestorePackageDownloadsTask 1 calls
1 ms JoinItems 1 calls
1 ms GetRestorePackageReferencesTask 1 calls
1 ms CreateWindowsSdkKnownFrameworkReferences 2 calls
1 ms ShowPreviewMessage 1 calls
1 ms GetRestoreDotnetCliToolsTask 1 calls
1 ms AllowEmptyTelemetry 2 calls
1 ms CreateCSharpManifestResourceName 1 calls
1 ms CheckForDuplicateItems 3 calls
1 ms AssignTargetPath 7 calls
1 ms ApplyImplicitVersions 2 calls
1 ms ReadLinesFromFile 1 calls
1 ms ConvertToAbsolutePath 3 calls
2 ms AssignCulture 2 calls
2 ms CreateItem 4 calls
2 ms Hash 3 calls
2 ms GetProjectTargetFrameworksTask 1 calls
2 ms GetPackageDirectory 8 calls
2 ms NuGetMessageTask 1 calls
2 ms CheckForImplicitPackageReferenceOverrides 2 calls
2 ms CheckIfPackageReferenceShouldBeFrameworkReference 4 calls
2 ms FindUnderPath 5 calls
3 ms GetRestoreProjectStyleTask 2 calls
3 ms GenerateMSBuildEditorConfig 1 calls
5 ms ResolvePackageFileConflicts 1 calls
6 ms RemoveDuplicates 7 calls
6 ms CallTarget 2 calls
7 ms ResolveTargetingPackAssets 1 calls
7 ms WarnForInvalidProjectsTask 1 calls
9 ms MakeDir 3 calls
14 ms WriteLinesToFile 3 calls
36 ms ResolveAppHosts 2 calls
39 ms GetRestoreSettingsTask 1 calls
87 ms ResolvePackageAssets 1 calls
101 ms GenerateDepsFile 1 calls
107 ms GenerateRuntimeConfigurationFiles 1 calls
117 ms ProcessFrameworkReferences 2 calls
169 ms ResolveAssemblyReference 1 calls
170 ms Copy 4 calls
170 ms CreateAppHost 1 calls
180 ms Csc 1 calls
327 ms RestoreTask 1 calls
349 ms MSBuild 7 calls
7014 ms Exec 1 calls
程序.cs
using System;
namespace testGame
{
public static class Program
{
[STAThread]
static void Main()
{
using (var game = new Game1())
game.Run();
}
}
}
Game1.cs
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
namespace testGame
{
public class Game1 : Game
{
private GraphicsDeviceManager _graphics;
private SpriteBatch _spriteBatch;
private Texture2D _balloon, _background;
private Color _pulsing;
private Vector2 _ballonPos;
public Game1()
{
_graphics = new GraphicsDeviceManager(this);
Content.RootDirectory = "Content";
IsMouseVisible = true;
}
protected override void Initialize()
{
// TODO: Add your initialization logic here
base.Initialize();
}
protected override void LoadContent()
{
_spriteBatch = new SpriteBatch(GraphicsDevice);
_balloon = Content.Load<Texture2D>("spr_lives");
_background = Content.Load<Texture2D>("spr_background");
MediaPlayer.Play(Content.Load<Song>("snd_music"));
}
protected override void Update(GameTime gameTime)
{
if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
Exit();
// TODO: Add your update logic here
base.Update(gameTime);
int redComponent = gameTime.TotalGameTime.Milliseconds / 4;
_pulsing = new Color(redComponent, 0, 0);
_ballonPos = Vector2.Zero;
}
protected override void Draw(GameTime gameTime)
{
GraphicsDevice.Clear(Color.White);
_spriteBatch.Begin();
_spriteBatch.Draw(_background, Vector2.Zero, Color.White);
_spriteBatch.Draw(_balloon, _ballonPos, _pulsing);
_spriteBatch.End();
base.Draw(gameTime);
}
}
testGame.csproj
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<PublishReadyToRun>false</PublishReadyToRun>
<TieredCompilation>false</TieredCompilation>
</PropertyGroup>
<PropertyGroup>
<ApplicationManifest>app.manifest</ApplicationManifest>
<ApplicationIcon>Icon.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
<None Remove="Icon.ico" />
<None Remove="Icon.bmp" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Icon.ico" />
<EmbeddedResource Include="Icon.bmp" />
</ItemGroup>
<ItemGroup>
<MonoGameContentReference Include="Content\Content.mgcb" />
</ItemGroup>
<ItemGroup>
<TrimmerRootAssembly Include="Microsoft.Xna.Framework.Content.ContentTypeReader" Visible="false" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="MonoGame.Framework.DesktopGL" Version="3.8.0.1641" />
<PackageReference Include="MonoGame.Content.Builder.Task" Version="3.8.0.1641" />
</ItemGroup>
</Project>
app.manifest
<?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="testGame"/>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
</requestedPrivileges>
</security>
</trustInfo>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- A list of the Windows versions that this application has been tested on and is
is designed to work with. Uncomment the appropriate elements and Windows will
automatically selected the most compatible environment. -->
<!-- Windows Vista -->
<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}" />
<!-- Windows 7 -->
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}" />
<!-- Windows 8 -->
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}" />
<!-- Windows 8.1 -->
<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}" />
<!-- Windows 10 -->
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />
</application>
</compatibility>
<application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings>
<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>
【问题讨论】:
-
我看到你在 r/MonoGame subreddit 上问了同样的问题,并得到了一些建议。如果您找到适合自己的东西,请在这里告诉我们,以防它帮助其他人。
标签: c# .net performance build monogame