• Which the release of FS2020 we see an explosition of activity on the forun and of course we are very happy to see this. But having all questions about FS2020 in one forum becomes a bit messy. So therefore we would like to ask you all to use the following guidelines when posting your questions:

    • Tag FS2020 specific questions with the MSFS2020 tag.
    • Questions about making 3D assets can be posted in the 3D asset design forum. Either post them in the subforum of the modelling tool you use or in the general forum if they are general.
    • Questions about aircraft design can be posted in the Aircraft design forum
    • Questions about airport design can be posted in the FS2020 airport design forum. Once airport development tools have been updated for FS2020 you can post tool speciifc questions in the subforums of those tools as well of course.
    • Questions about terrain design can be posted in the FS2020 terrain design forum.
    • Questions about SimConnect can be posted in the SimConnect forum.

    Any other question that is not specific to an aspect of development or tool can be posted in the General chat forum.

    By following these guidelines we make sure that the forums remain easy to read for everybody and also that the right people can find your post to answer it.

Trying to share simple app with friend

Messages
4
Country
us-newyork
Like many...I am in the early layers of the simconnect rabbit hole. I do have an app that works on my machine though and I want to figure out what the process is for getting the app to someone else for them to try. I read that I needed to add post-build events to get the dll's to copy over after building, but I get errors when I try to build with these entered:
Code:
xcopy “$(ProjectDir)SimConnect.dll” "$(TargetDir)" /Y
xcopy “$(ProjectDir)Microsoft.FlightSimulator.SimConnect.dll” "$(TargetDir)" /Y

It says it fails with error code 4 (can't find the files), but they are 100% in the location I'm pointing to.
 
Messages
69
Country
us-newyork
Hi,

The managed DLL should already be in the build folder since it should be a reference. If it's not, how are you linking/referencing it in your project file?

I'm not sure $(ProjectDir) resolves correctly in all situations. I've had more luck with $(SolutionDir) or relative paths.
Also in this particular case, if you have the SimConnect SDK installed on the build machine (or accessible via UNC), you could use the environment variable $(MSFS_SDK) to locate the DLLs (examples below).

The C SimConnect.dll can be automatically copied into your build folder by using something like this in the project file. Adjust the "Include" path as needed. The "lib" folder referenced below is a subfolder of the current project. TargetPathis where the DLL will be copied to, including the file name, relative to the root build directory (so it ends up with all the other binaries).

XML:
  <ItemGroup>
    <ContentWithTargetPath Include=".\lib\SimConnect.dll">
    <!-- <ContentWithTargetPath Include="$(MSFS_SDK)\SimConnect SDK\lib\static\SimConnect.dll"> -->
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
      <TargetPath>SimConnect.dll</TargetPath>
    </ContentWithTargetPath>
  </ItemGroup>

For completeness, here's how I have both DLLs listed in a project file:

XML:
  <!-- SimConnect libs -->
  <ItemGroup>
    <Reference Include="Microsoft.FlightSimulator.SimConnect">
      <HintPath>.\lib\Microsoft.FlightSimulator.SimConnect.dll</HintPath>
      <!-- <HintPath>$(MSFS_SDK)\SimConnect SDK\lib\managed\Microsoft.FlightSimulator.SimConnect.dll</HintPath> -->
      <EmbedInteropTypes>false</EmbedInteropTypes>
      <Private>true</Private>
    </Reference>
    <ContentWithTargetPath Include=".\lib\SimConnect.dll">
    <!-- <ContentWithTargetPath Include="$(MSFS_SDK)\SimConnect SDK\lib\static\SimConnect.dll"> -->
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
      <TargetPath>SimConnect.dll</TargetPath>
    </ContentWithTargetPath>
  </ItemGroup>

HTH,
-Max
 
Messages
4
Country
us-newyork
Hey Max,

Thanks a lot for your response. My understanding is the post-build code generates these XML tags when you set it up the project properties. Do you have the code equivalent that I would past in that properties window to generate what you included above? I've tried to edit the project file before and it let to all sorts of issues, I don't actually know why it doesn't show up in my visual studio solution pane.
 
Messages
69
Country
us-newyork
My understanding is the post-build code generates these XML tags when you set it up the project properties.
That's incorrect. IIRC there's a way via the Solution Explorer to include a file in a project and set the properties on it like `CopyToOutputDirectory` and `TargetPath`. Which then generates something similar in the project file.
Similar for the managed DLL, but again IIRC those properties are set on the dependency/reference entry which should already be present in your project.

Do you have the code equivalent that I would past in that properties window to generate what you included above?
Which properties window?

I've tried to edit the project file before and it let to all sorts of issues,
I know nothing about your project except that it uses SimConnect and .NET 6 somehow.... not much to go on. :)

Personally I can't stand the .NET GUI project properties editor, which is even worse now in VS2022. But anyway I think the GUI way to achieve the same thing is via the Solution Explorer.

I don't actually know why it doesn't show up in my visual studio solution pane.
Not sure which "it" you're referring to here.

Cheers,
-Max
 
Messages
4
Country
us-newyork
That's incorrect. IIRC there's a way via the Solution Explorer to include a file in a project and set the properties on it like `CopyToOutputDirectory` and `TargetPath`. Which then generates something similar in the project file.
Similar for the managed DLL, but again IIRC those properties are set on the dependency/reference entry which should already be present in your project.
1685105327074.png

This is the build events window I was trying to use to accomplish this. Some of the material I was reading was a few years old so not sure if this is the right way to approach it or if I should do this via the solution explorer as you suggested.
I know nothing about your project except that it uses SimConnect and .NET 6 somehow.... not much to go on. :)
I downloaded another member's example to learn from (the ones that came with the SDK were too advanced for me to tease apart). That demo has a TITLE.csproj file in the directory. I also have one, but I can't open it to edit it in my project like I can in the demo's. I can open it in notepad to edit the XML but VS doesn't seem to like that very much after saving. That file is the "it" I was referring to.
 

rhumbaflappy

Administrator
Staff member
Resource contributor
Messages
5,725
Country
us-wisconsin
In VS2022:
managedDLL.png


unmanagedDLL.png


These will copy the DLLs to the bin|release and bin|Debug. From there you just need to create a folder on the desktop, copy the EXE and the 2 DLLs to that new folder, zip it and send it. Like the attached zip. That can be unzipped anywhere in the user's computer, and a shortcut of the EXE made on the desktop.
 

Attachments

  • MyTCalc.zip
    82.2 KB · Views: 19
Top